mirror of
https://github.com/ValveSoftware/Proton.git
synced 2024-12-25 14:15:45 +03:00
lsteamclient: Avoid code duplication in handling SteamNetworkingMessage_t wrapping.
CW-Bug-Id: #22649
This commit is contained in:
parent
6d51ed29f3
commit
6ed890c9e9
@ -15,6 +15,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
||||
#pragma pop_macro("__cdecl")
|
||||
#include "steamclient_private.h"
|
||||
|
||||
#define SDK_VERSION 992
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
class ISteamUser_linux
|
||||
{
|
||||
public:
|
||||
|
@ -15,6 +15,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
||||
#pragma pop_macro("__cdecl")
|
||||
#include "steamclient_private.h"
|
||||
|
||||
#define SDK_VERSION 1410
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
const char * cppISteamController_SteamController005_GetGlyphForActionOrigin(void *linux_side, EControllerActionOrigin eOrigin)
|
||||
|
@ -15,6 +15,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
||||
#pragma pop_macro("__cdecl")
|
||||
#include "steamclient_private.h"
|
||||
|
||||
#define SDK_VERSION 1420
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
const char * cppISteamController_SteamController006_GetGlyphForActionOrigin(void *linux_side, EControllerActionOrigin eOrigin)
|
||||
|
@ -23,105 +23,8 @@ extern "C" {
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
/***** manual struct converter for SteamNetworkingMessage_t *****/
|
||||
|
||||
struct msg_wrapper {
|
||||
struct winSteamNetworkingMessage_t_144 win_msg;
|
||||
struct SteamNetworkingMessage_t *lin_msg;
|
||||
|
||||
void (*orig_FreeData)(SteamNetworkingMessage_t *);
|
||||
|
||||
SLIST_ENTRY(msg_wrapper) entry;
|
||||
};
|
||||
|
||||
static SLIST_HEAD(free_msgs_head, msg_wrapper) free_msgs = SLIST_HEAD_INITIALIZER(free_msgs);
|
||||
static CRITICAL_SECTION free_msgs_lock = { NULL, -1, 0, 0, 0, 0 };
|
||||
|
||||
static void __attribute__((ms_abi)) win_FreeData(struct winSteamNetworkingMessage_t_144 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->orig_FreeData)
|
||||
{
|
||||
msg->lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
msg->orig_FreeData(msg->lin_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((ms_abi)) win_Release(struct winSteamNetworkingMessage_t_144 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
msg->lin_msg->m_pfnRelease(msg->lin_msg);
|
||||
msg->lin_msg = NULL;
|
||||
msg->orig_FreeData = NULL;
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
SLIST_INSERT_HEAD(&free_msgs, msg, entry);
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
}
|
||||
|
||||
static void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = (struct msg_wrapper *)lin_msg->m_pData; /* ! see assignment, below */
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->win_msg.m_pfnFreeData)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_144 *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_144(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_144 **w, int max_messages)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n_messages > 0)
|
||||
TRACE("%u %p %p\n", n_messages, l, w);
|
||||
|
||||
for(i = 0; i < n_messages; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg = SLIST_FIRST(&free_msgs);
|
||||
|
||||
if(!msg){
|
||||
int n;
|
||||
/* allocs can be pricey, so alloc in blocks */
|
||||
#define MSGS_PER_BLOCK 16
|
||||
struct msg_wrapper *msgs = (struct msg_wrapper *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct msg_wrapper) * MSGS_PER_BLOCK);
|
||||
for(n = 1; n < MSGS_PER_BLOCK; ++n)
|
||||
SLIST_INSERT_HEAD(&free_msgs, &msgs[n], entry);
|
||||
msg = &msgs[0];
|
||||
}else
|
||||
SLIST_REMOVE_HEAD(&free_msgs, entry);
|
||||
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg->lin_msg = l[i];
|
||||
|
||||
msg->win_msg.m_pData = msg->lin_msg->m_pData;
|
||||
msg->win_msg.m_cbSize = msg->lin_msg->m_cbSize;
|
||||
msg->win_msg.m_conn = msg->lin_msg->m_conn;
|
||||
msg->win_msg.m_sender = msg->lin_msg->m_sender;
|
||||
msg->win_msg.m_nConnUserData = msg->lin_msg->m_nConnUserData;
|
||||
msg->win_msg.m_usecTimeReceived= msg->lin_msg->m_usecTimeReceived;
|
||||
msg->win_msg.m_nMessageNumber = msg->lin_msg->m_nMessageNumber;
|
||||
msg->win_msg.m_pfnFreeData = (void*)win_FreeData;
|
||||
msg->win_msg.m_pfnRelease = (void*)win_Release;
|
||||
msg->win_msg.m_nChannel = msg->lin_msg->m_nChannel;
|
||||
msg->win_msg.m___nPadDummy = msg->lin_msg->m___nPadDummy;
|
||||
|
||||
msg->orig_FreeData = msg->lin_msg->m_pfnFreeData;
|
||||
msg->lin_msg->m_pfnFreeData = lin_FreeData;
|
||||
/* ! store the wrapper here and restore the original pointer from win_msg before calling orig_FreeData */
|
||||
msg->lin_msg->m_pData = msg;
|
||||
|
||||
w[i] = &msg->win_msg;
|
||||
TRACE("done with %u, returned wrapper %p\n", i, msg);
|
||||
}
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
#define SDK_VERSION 1440
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets002_ReceiveMessagesOnConnection(
|
||||
void *linux_side, HSteamNetConnection hConn,
|
||||
@ -129,7 +32,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets002_ReceiveMessagesOnConnec
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection(hConn, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_144(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -139,7 +42,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets002_ReceiveMessagesOnListen
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnListenSocket(hSocket, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_144(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -24,115 +24,8 @@ extern "C" {
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
/***** manual struct converter for SteamNetworkingMessage_t *****/
|
||||
|
||||
struct msg_wrapper {
|
||||
struct winSteamNetworkingMessage_t_146 win_msg;
|
||||
struct SteamNetworkingMessage_t *lin_msg;
|
||||
|
||||
void (*orig_FreeData)(SteamNetworkingMessage_t *);
|
||||
|
||||
SLIST_ENTRY(msg_wrapper) entry;
|
||||
};
|
||||
|
||||
static SLIST_HEAD(free_msgs_head, msg_wrapper) free_msgs = SLIST_HEAD_INITIALIZER(free_msgs);
|
||||
static CRITICAL_SECTION free_msgs_lock = { NULL, -1, 0, 0, 0, 0 };
|
||||
|
||||
static void __attribute__((ms_abi)) win_FreeData(struct winSteamNetworkingMessage_t_146 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->orig_FreeData)
|
||||
{
|
||||
msg->lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
msg->orig_FreeData(msg->lin_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((ms_abi)) win_Release(struct winSteamNetworkingMessage_t_146 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
msg->lin_msg->m_pfnRelease(msg->lin_msg);
|
||||
msg->lin_msg = NULL;
|
||||
msg->orig_FreeData = NULL;
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
SLIST_INSERT_HEAD(&free_msgs, msg, entry);
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
}
|
||||
|
||||
static void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = (struct msg_wrapper *)lin_msg->m_pData; /* ! see assignment, below */
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->win_msg.m_pfnFreeData)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_146 *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
static struct msg_wrapper *clone_msg(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg = SLIST_FIRST(&free_msgs);
|
||||
|
||||
if(!msg){
|
||||
int n;
|
||||
/* allocs can be pricey, so alloc in blocks */
|
||||
#define MSGS_PER_BLOCK 16
|
||||
struct msg_wrapper *msgs = (struct msg_wrapper *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct msg_wrapper) * MSGS_PER_BLOCK);
|
||||
for(n = 1; n < MSGS_PER_BLOCK; ++n)
|
||||
SLIST_INSERT_HEAD(&free_msgs, &msgs[n], entry);
|
||||
msg = &msgs[0];
|
||||
}else
|
||||
SLIST_REMOVE_HEAD(&free_msgs, entry);
|
||||
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg->lin_msg = lin_msg;
|
||||
|
||||
msg->win_msg.m_pData = msg->lin_msg->m_pData;
|
||||
msg->win_msg.m_cbSize = msg->lin_msg->m_cbSize;
|
||||
msg->win_msg.m_conn = msg->lin_msg->m_conn;
|
||||
msg->win_msg.m_sender = msg->lin_msg->m_sender;
|
||||
msg->win_msg.m_nConnUserData = msg->lin_msg->m_nConnUserData;
|
||||
msg->win_msg.m_usecTimeReceived= msg->lin_msg->m_usecTimeReceived;
|
||||
msg->win_msg.m_nMessageNumber = msg->lin_msg->m_nMessageNumber;
|
||||
msg->win_msg.m_pfnFreeData = (void*)win_FreeData;
|
||||
msg->win_msg.m_pfnRelease = (void*)win_Release;
|
||||
msg->win_msg.m_nChannel = msg->lin_msg->m_nChannel;
|
||||
msg->win_msg.m___nPadDummy = msg->lin_msg->m___nPadDummy;
|
||||
|
||||
msg->orig_FreeData = msg->lin_msg->m_pfnFreeData;
|
||||
msg->lin_msg->m_pfnFreeData = lin_FreeData;
|
||||
/* ! store the wrapper here and restore the original pointer from win_msg before calling orig_FreeData */
|
||||
msg->lin_msg->m_pData = msg;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_146(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_146 **w, int max_messages)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n_messages > 0)
|
||||
TRACE("%u %p %p\n", n_messages, l, w);
|
||||
|
||||
for(i = 0; i < n_messages; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
msg = clone_msg(l[i]);
|
||||
|
||||
w[i] = &msg->win_msg;
|
||||
|
||||
TRACE("done with %u, returned wrapper %p\n", i, msg);
|
||||
}
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
#define SDK_VERSION 1460
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets004_ReceiveMessagesOnConnection(
|
||||
void *linux_side, HSteamNetConnection hConn,
|
||||
@ -140,7 +33,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets004_ReceiveMessagesOnConnec
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection(hConn, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_146(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -150,7 +43,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets004_ReceiveMessagesOnListen
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnListenSocket(hSocket, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_146(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -24,116 +24,8 @@ extern "C" {
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
/***** manual struct converter for SteamNetworkingMessage_t *****/
|
||||
|
||||
struct msg_wrapper {
|
||||
struct winSteamNetworkingMessage_t_147 win_msg;
|
||||
struct SteamNetworkingMessage_t *lin_msg;
|
||||
|
||||
void (*orig_FreeData)(SteamNetworkingMessage_t *);
|
||||
|
||||
SLIST_ENTRY(msg_wrapper) entry;
|
||||
};
|
||||
|
||||
static SLIST_HEAD(free_msgs_head, msg_wrapper) free_msgs = SLIST_HEAD_INITIALIZER(free_msgs);
|
||||
static CRITICAL_SECTION free_msgs_lock = { NULL, -1, 0, 0, 0, 0 };
|
||||
|
||||
static void __attribute__((ms_abi)) win_FreeData(struct winSteamNetworkingMessage_t_147 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->orig_FreeData)
|
||||
{
|
||||
msg->lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
msg->orig_FreeData(msg->lin_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((ms_abi)) win_Release(struct winSteamNetworkingMessage_t_147 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
msg->lin_msg->m_pfnRelease(msg->lin_msg);
|
||||
msg->lin_msg = NULL;
|
||||
msg->orig_FreeData = NULL;
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
SLIST_INSERT_HEAD(&free_msgs, msg, entry);
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
}
|
||||
|
||||
static void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = (struct msg_wrapper *)lin_msg->m_pData; /* ! see assignment, below */
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->win_msg.m_pfnFreeData)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_147 *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
static struct msg_wrapper *clone_msg(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg = SLIST_FIRST(&free_msgs);
|
||||
|
||||
if(!msg){
|
||||
int n;
|
||||
/* allocs can be pricey, so alloc in blocks */
|
||||
#define MSGS_PER_BLOCK 16
|
||||
struct msg_wrapper *msgs = (struct msg_wrapper *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct msg_wrapper) * MSGS_PER_BLOCK);
|
||||
for(n = 1; n < MSGS_PER_BLOCK; ++n)
|
||||
SLIST_INSERT_HEAD(&free_msgs, &msgs[n], entry);
|
||||
msg = &msgs[0];
|
||||
}else
|
||||
SLIST_REMOVE_HEAD(&free_msgs, entry);
|
||||
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg->lin_msg = lin_msg;
|
||||
|
||||
msg->win_msg.m_pData = msg->lin_msg->m_pData;
|
||||
msg->win_msg.m_cbSize = msg->lin_msg->m_cbSize;
|
||||
msg->win_msg.m_conn = msg->lin_msg->m_conn;
|
||||
msg->win_msg.m_identityPeer = msg->lin_msg->m_identityPeer;
|
||||
msg->win_msg.m_nConnUserData = msg->lin_msg->m_nConnUserData;
|
||||
msg->win_msg.m_usecTimeReceived= msg->lin_msg->m_usecTimeReceived;
|
||||
msg->win_msg.m_nMessageNumber = msg->lin_msg->m_nMessageNumber;
|
||||
msg->win_msg.m_pfnFreeData = (void*)win_FreeData;
|
||||
msg->win_msg.m_pfnRelease = (void*)win_Release;
|
||||
msg->win_msg.m_nChannel = msg->lin_msg->m_nChannel;
|
||||
msg->win_msg.m_nFlags = msg->lin_msg->m_nFlags;
|
||||
msg->win_msg.m_nUserData = msg->lin_msg->m_nUserData;
|
||||
|
||||
msg->orig_FreeData = msg->lin_msg->m_pfnFreeData;
|
||||
msg->lin_msg->m_pfnFreeData = lin_FreeData;
|
||||
/* ! store the wrapper here and restore the original pointer from win_msg before calling orig_FreeData */
|
||||
msg->lin_msg->m_pData = msg;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_147(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_147 **w, int max_messages)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n_messages > 0)
|
||||
TRACE("%u %p %p\n", n_messages, l, w);
|
||||
|
||||
for(i = 0; i < n_messages; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
msg = clone_msg(l[i]);
|
||||
|
||||
w[i] = &msg->win_msg;
|
||||
|
||||
TRACE("done with %u, returned wrapper %p\n", i, msg);
|
||||
}
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
#define SDK_VERSION 1470
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets006_ReceiveMessagesOnConnection(
|
||||
void *linux_side, HSteamNetConnection hConn,
|
||||
@ -141,7 +33,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets006_ReceiveMessagesOnConnec
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection(hConn, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_147(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -151,7 +43,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets006_ReceiveMessagesOnListen
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnListenSocket(hSocket, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_147(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -173,21 +65,7 @@ void cppISteamNetworkingSockets_SteamNetworkingSockets006_SendMessages(
|
||||
while(nMessages)
|
||||
{
|
||||
for(i = 0; i < nMessages && i < MAX_SEND_MESSAGES; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(pMessages[i], struct msg_wrapper, win_msg);
|
||||
lin_msgs[i] = msg->lin_msg;
|
||||
|
||||
lin_msgs[i]->m_pData = msg->win_msg.m_pData;
|
||||
lin_msgs[i]->m_cbSize = msg->win_msg.m_cbSize;
|
||||
lin_msgs[i]->m_conn = msg->win_msg.m_conn;
|
||||
lin_msgs[i]->m_identityPeer = msg->win_msg.m_identityPeer;
|
||||
lin_msgs[i]->m_nConnUserData = msg->win_msg.m_nConnUserData;
|
||||
lin_msgs[i]->m_usecTimeReceived= msg->win_msg.m_usecTimeReceived;
|
||||
lin_msgs[i]->m_nMessageNumber = msg->win_msg.m_nMessageNumber;
|
||||
lin_msgs[i]->m_nChannel = msg->win_msg.m_nChannel;
|
||||
lin_msgs[i]->m_nFlags = msg->win_msg.m_nFlags;
|
||||
lin_msgs[i]->m_nUserData = msg->win_msg.m_nUserData;
|
||||
}
|
||||
lin_msgs[i] = (SteamNetworkingMessage_t *)network_message_win_to_lin(pMessages[i]);
|
||||
|
||||
((ISteamNetworkingSockets*)linux_side)->SendMessages(i, lin_msgs, pOutMessageNumberOrResult);
|
||||
|
||||
|
@ -24,116 +24,8 @@ extern "C" {
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
/***** manual struct converter for SteamNetworkingMessage_t *****/
|
||||
|
||||
struct msg_wrapper {
|
||||
struct winSteamNetworkingMessage_t_148a win_msg;
|
||||
struct SteamNetworkingMessage_t *lin_msg;
|
||||
|
||||
void (*orig_FreeData)(SteamNetworkingMessage_t *);
|
||||
|
||||
SLIST_ENTRY(msg_wrapper) entry;
|
||||
};
|
||||
|
||||
static SLIST_HEAD(free_msgs_head, msg_wrapper) free_msgs = SLIST_HEAD_INITIALIZER(free_msgs);
|
||||
static CRITICAL_SECTION free_msgs_lock = { NULL, -1, 0, 0, 0, 0 };
|
||||
|
||||
static void __attribute__((ms_abi)) win_FreeData(struct winSteamNetworkingMessage_t_148a *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->orig_FreeData)
|
||||
{
|
||||
msg->lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
msg->orig_FreeData(msg->lin_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((ms_abi)) win_Release(struct winSteamNetworkingMessage_t_148a *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
msg->lin_msg->m_pfnRelease(msg->lin_msg);
|
||||
msg->lin_msg = NULL;
|
||||
msg->orig_FreeData = NULL;
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
SLIST_INSERT_HEAD(&free_msgs, msg, entry);
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
}
|
||||
|
||||
static void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = (struct msg_wrapper *)lin_msg->m_pData; /* ! see assignment, below */
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->win_msg.m_pfnFreeData)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_148a *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
static struct msg_wrapper *clone_msg(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg = SLIST_FIRST(&free_msgs);
|
||||
|
||||
if(!msg){
|
||||
int n;
|
||||
/* allocs can be pricey, so alloc in blocks */
|
||||
#define MSGS_PER_BLOCK 16
|
||||
struct msg_wrapper *msgs = (struct msg_wrapper *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct msg_wrapper) * MSGS_PER_BLOCK);
|
||||
for(n = 1; n < MSGS_PER_BLOCK; ++n)
|
||||
SLIST_INSERT_HEAD(&free_msgs, &msgs[n], entry);
|
||||
msg = &msgs[0];
|
||||
}else
|
||||
SLIST_REMOVE_HEAD(&free_msgs, entry);
|
||||
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg->lin_msg = lin_msg;
|
||||
|
||||
msg->win_msg.m_pData = msg->lin_msg->m_pData;
|
||||
msg->win_msg.m_cbSize = msg->lin_msg->m_cbSize;
|
||||
msg->win_msg.m_conn = msg->lin_msg->m_conn;
|
||||
msg->win_msg.m_identityPeer = msg->lin_msg->m_identityPeer;
|
||||
msg->win_msg.m_nConnUserData = msg->lin_msg->m_nConnUserData;
|
||||
msg->win_msg.m_usecTimeReceived= msg->lin_msg->m_usecTimeReceived;
|
||||
msg->win_msg.m_nMessageNumber = msg->lin_msg->m_nMessageNumber;
|
||||
msg->win_msg.m_pfnFreeData = (void*)win_FreeData;
|
||||
msg->win_msg.m_pfnRelease = (void*)win_Release;
|
||||
msg->win_msg.m_nChannel = msg->lin_msg->m_nChannel;
|
||||
msg->win_msg.m_nFlags = msg->lin_msg->m_nFlags;
|
||||
msg->win_msg.m_nUserData = msg->lin_msg->m_nUserData;
|
||||
|
||||
msg->orig_FreeData = msg->lin_msg->m_pfnFreeData;
|
||||
msg->lin_msg->m_pfnFreeData = lin_FreeData;
|
||||
/* ! store the wrapper here and restore the original pointer from win_msg before calling orig_FreeData */
|
||||
msg->lin_msg->m_pData = msg;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_148a(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_148a **w, int max_messages)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n_messages > 0)
|
||||
TRACE("%u %p %p\n", n_messages, l, w);
|
||||
|
||||
for(i = 0; i < n_messages; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
msg = clone_msg(l[i]);
|
||||
|
||||
w[i] = &msg->win_msg;
|
||||
|
||||
TRACE("done with %u, returned wrapper %p\n", i, msg);
|
||||
}
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
#define SDK_VERSION 1481
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets008_ReceiveMessagesOnConnection(
|
||||
void *linux_side, HSteamNetConnection hConn,
|
||||
@ -141,7 +33,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets008_ReceiveMessagesOnConnec
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection(hConn, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_148a(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -151,7 +43,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets008_ReceiveMessagesOnPollGr
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnPollGroup(hPollGroup, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_148a(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -173,21 +65,7 @@ void cppISteamNetworkingSockets_SteamNetworkingSockets008_SendMessages(
|
||||
while(nMessages)
|
||||
{
|
||||
for(i = 0; i < nMessages && i < MAX_SEND_MESSAGES; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(pMessages[i], struct msg_wrapper, win_msg);
|
||||
lin_msgs[i] = msg->lin_msg;
|
||||
|
||||
lin_msgs[i]->m_pData = msg->win_msg.m_pData;
|
||||
lin_msgs[i]->m_cbSize = msg->win_msg.m_cbSize;
|
||||
lin_msgs[i]->m_conn = msg->win_msg.m_conn;
|
||||
lin_msgs[i]->m_identityPeer = msg->win_msg.m_identityPeer;
|
||||
lin_msgs[i]->m_nConnUserData = msg->win_msg.m_nConnUserData;
|
||||
lin_msgs[i]->m_usecTimeReceived= msg->win_msg.m_usecTimeReceived;
|
||||
lin_msgs[i]->m_nMessageNumber = msg->win_msg.m_nMessageNumber;
|
||||
lin_msgs[i]->m_nChannel = msg->win_msg.m_nChannel;
|
||||
lin_msgs[i]->m_nFlags = msg->win_msg.m_nFlags;
|
||||
lin_msgs[i]->m_nUserData = msg->win_msg.m_nUserData;
|
||||
}
|
||||
lin_msgs[i] = (SteamNetworkingMessage_t *)network_message_win_to_lin(pMessages[i]);
|
||||
|
||||
((ISteamNetworkingSockets*)linux_side)->SendMessages(i, lin_msgs, pOutMessageNumberOrResult);
|
||||
|
||||
@ -201,12 +79,9 @@ void cppISteamNetworkingSockets_SteamNetworkingSockets008_SendMessages(
|
||||
SteamNetworkingMessage_t *cppISteamNetworkingUtils_SteamNetworkingUtils003_AllocateMessage(
|
||||
void *linux_side, int cbAllocateBuffer)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
SteamNetworkingMessage_t *retval = ((ISteamNetworkingUtils*)linux_side)->AllocateMessage(cbAllocateBuffer);
|
||||
|
||||
msg = clone_msg(retval);
|
||||
|
||||
return (SteamNetworkingMessage_t*)&msg->win_msg;
|
||||
return (SteamNetworkingMessage_t *)network_message_lin_to_win(retval);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,116 +25,8 @@ extern "C" {
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
/***** manual struct converter for SteamNetworkingMessage_t *****/
|
||||
|
||||
struct msg_wrapper {
|
||||
struct winSteamNetworkingMessage_t_150 win_msg;
|
||||
struct SteamNetworkingMessage_t *lin_msg;
|
||||
|
||||
void (*orig_FreeData)(SteamNetworkingMessage_t *);
|
||||
|
||||
SLIST_ENTRY(msg_wrapper) entry;
|
||||
};
|
||||
|
||||
static SLIST_HEAD(free_msgs_head, msg_wrapper) free_msgs = SLIST_HEAD_INITIALIZER(free_msgs);
|
||||
static CRITICAL_SECTION free_msgs_lock = { NULL, -1, 0, 0, 0, 0 };
|
||||
|
||||
static void __attribute__((ms_abi)) win_FreeData(struct winSteamNetworkingMessage_t_150 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->orig_FreeData)
|
||||
{
|
||||
msg->lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
msg->orig_FreeData(msg->lin_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((ms_abi)) win_Release(struct winSteamNetworkingMessage_t_150 *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
msg->lin_msg->m_pfnRelease(msg->lin_msg);
|
||||
msg->lin_msg = NULL;
|
||||
msg->orig_FreeData = NULL;
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
SLIST_INSERT_HEAD(&free_msgs, msg, entry);
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
}
|
||||
|
||||
static void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = (struct msg_wrapper *)lin_msg->m_pData; /* ! see assignment, below */
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->win_msg.m_pfnFreeData)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_150 *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
static struct msg_wrapper *clone_msg(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg = SLIST_FIRST(&free_msgs);
|
||||
|
||||
if(!msg){
|
||||
int n;
|
||||
/* allocs can be pricey, so alloc in blocks */
|
||||
#define MSGS_PER_BLOCK 16
|
||||
struct msg_wrapper *msgs = (struct msg_wrapper *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct msg_wrapper) * MSGS_PER_BLOCK);
|
||||
for(n = 1; n < MSGS_PER_BLOCK; ++n)
|
||||
SLIST_INSERT_HEAD(&free_msgs, &msgs[n], entry);
|
||||
msg = &msgs[0];
|
||||
}else
|
||||
SLIST_REMOVE_HEAD(&free_msgs, entry);
|
||||
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg->lin_msg = lin_msg;
|
||||
|
||||
msg->win_msg.m_pData = msg->lin_msg->m_pData;
|
||||
msg->win_msg.m_cbSize = msg->lin_msg->m_cbSize;
|
||||
msg->win_msg.m_conn = msg->lin_msg->m_conn;
|
||||
msg->win_msg.m_identityPeer = msg->lin_msg->m_identityPeer;
|
||||
msg->win_msg.m_nConnUserData = msg->lin_msg->m_nConnUserData;
|
||||
msg->win_msg.m_usecTimeReceived= msg->lin_msg->m_usecTimeReceived;
|
||||
msg->win_msg.m_nMessageNumber = msg->lin_msg->m_nMessageNumber;
|
||||
msg->win_msg.m_pfnFreeData = (void*)win_FreeData;
|
||||
msg->win_msg.m_pfnRelease = (void*)win_Release;
|
||||
msg->win_msg.m_nChannel = msg->lin_msg->m_nChannel;
|
||||
msg->win_msg.m_nFlags = msg->lin_msg->m_nFlags;
|
||||
msg->win_msg.m_nUserData = msg->lin_msg->m_nUserData;
|
||||
|
||||
msg->orig_FreeData = msg->lin_msg->m_pfnFreeData;
|
||||
msg->lin_msg->m_pfnFreeData = lin_FreeData;
|
||||
/* ! store the wrapper here and restore the original pointer from win_msg before calling orig_FreeData */
|
||||
msg->lin_msg->m_pData = msg;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_150(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_150 **w, int max_messages)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n_messages > 0)
|
||||
TRACE("%u %p %p\n", n_messages, l, w);
|
||||
|
||||
for(i = 0; i < n_messages; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
msg = clone_msg(l[i]);
|
||||
|
||||
w[i] = &msg->win_msg;
|
||||
|
||||
TRACE("done with %u, returned wrapper %p\n", i, msg);
|
||||
}
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
#define SDK_VERSION 1500
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets009_ReceiveMessagesOnConnection(
|
||||
void *linux_side, HSteamNetConnection hConn,
|
||||
@ -142,7 +34,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets009_ReceiveMessagesOnConnec
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection(hConn, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_150(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -152,7 +44,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets009_ReceiveMessagesOnPollGr
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnPollGroup(hPollGroup, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_150(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -174,21 +66,7 @@ void cppISteamNetworkingSockets_SteamNetworkingSockets009_SendMessages(
|
||||
while(nMessages)
|
||||
{
|
||||
for(i = 0; i < nMessages && i < MAX_SEND_MESSAGES; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(pMessages[i], struct msg_wrapper, win_msg);
|
||||
lin_msgs[i] = msg->lin_msg;
|
||||
|
||||
lin_msgs[i]->m_pData = msg->win_msg.m_pData;
|
||||
lin_msgs[i]->m_cbSize = msg->win_msg.m_cbSize;
|
||||
lin_msgs[i]->m_conn = msg->win_msg.m_conn;
|
||||
lin_msgs[i]->m_identityPeer = msg->win_msg.m_identityPeer;
|
||||
lin_msgs[i]->m_nConnUserData = msg->win_msg.m_nConnUserData;
|
||||
lin_msgs[i]->m_usecTimeReceived= msg->win_msg.m_usecTimeReceived;
|
||||
lin_msgs[i]->m_nMessageNumber = msg->win_msg.m_nMessageNumber;
|
||||
lin_msgs[i]->m_nChannel = msg->win_msg.m_nChannel;
|
||||
lin_msgs[i]->m_nFlags = msg->win_msg.m_nFlags;
|
||||
lin_msgs[i]->m_nUserData = msg->win_msg.m_nUserData;
|
||||
}
|
||||
lin_msgs[i] = (SteamNetworkingMessage_t *)network_message_win_to_lin(pMessages[i]);
|
||||
|
||||
((ISteamNetworkingSockets*)linux_side)->SendMessages(i, lin_msgs, pOutMessageNumberOrResult);
|
||||
|
||||
@ -205,7 +83,7 @@ int cppISteamNetworkingMessages_SteamNetworkingMessages002_ReceiveMessagesOnChan
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingMessages*)linux_side)->ReceiveMessagesOnChannel(nLocalChannel, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_150(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,9 @@ extern "C" {
|
||||
#include "struct_converters.h"
|
||||
#include "cb_converters.h"
|
||||
|
||||
#define SDK_VERSION 1510
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
const char * cppISteamInput_SteamInput002_GetGlyphForActionOrigin(void *linux_side, EInputActionOrigin eOrigin)
|
||||
{
|
||||
const char *path_result;
|
||||
|
@ -23,6 +23,9 @@ extern "C" {
|
||||
#include "struct_converters.h"
|
||||
#include "cb_converters.h"
|
||||
|
||||
#define SDK_VERSION 1520
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
/***** manual fn wrapper for ISteamInput::EnableActionEventCallbacks *****/
|
||||
win_SteamInputActionEventCallbackPointer win_EnableActionEventCallbacks;
|
||||
|
||||
|
@ -27,6 +27,9 @@ extern "C" {
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
#define SDK_VERSION 1531
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
/***** manual fn wrapper for ISteamInput::EnableActionEventCallbacks *****/
|
||||
extern win_SteamInputActionEventCallbackPointer win_EnableActionEventCallbacks;
|
||||
|
||||
@ -36,127 +39,13 @@ void cppISteamInput_SteamInput006_EnableActionEventCallbacks(void *linux_side, w
|
||||
((ISteamInput*)linux_side)->EnableActionEventCallbacks(pCallback ? &lin_SteamInputActionEventCallbackPointer : NULL);
|
||||
}
|
||||
|
||||
|
||||
/***** manual struct converter for SteamNetworkingMessage_t *****/
|
||||
|
||||
struct msg_wrapper {
|
||||
struct winSteamNetworkingMessage_t_153a win_msg;
|
||||
struct SteamNetworkingMessage_t *lin_msg;
|
||||
|
||||
void (*orig_FreeData)(SteamNetworkingMessage_t *);
|
||||
|
||||
SLIST_ENTRY(msg_wrapper) entry;
|
||||
};
|
||||
|
||||
static SLIST_HEAD(free_msgs_head, msg_wrapper) free_msgs = SLIST_HEAD_INITIALIZER(free_msgs);
|
||||
static CRITICAL_SECTION free_msgs_lock = { NULL, -1, 0, 0, 0, 0 };
|
||||
|
||||
static void __attribute__((ms_abi)) win_FreeData(struct winSteamNetworkingMessage_t_153a *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->orig_FreeData)
|
||||
{
|
||||
msg->lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
msg->orig_FreeData(msg->lin_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((ms_abi)) win_Release(struct winSteamNetworkingMessage_t_153a *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
msg->lin_msg->m_pfnRelease(msg->lin_msg);
|
||||
msg->lin_msg = NULL;
|
||||
msg->orig_FreeData = NULL;
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
SLIST_INSERT_HEAD(&free_msgs, msg, entry);
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
}
|
||||
|
||||
static void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = (struct msg_wrapper *)lin_msg->m_pData; /* ! see assignment, below */
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->win_msg.m_pfnFreeData)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_153a *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
static struct msg_wrapper *clone_msg(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg = SLIST_FIRST(&free_msgs);
|
||||
|
||||
if(!msg){
|
||||
int n;
|
||||
/* allocs can be pricey, so alloc in blocks */
|
||||
#define MSGS_PER_BLOCK 16
|
||||
struct msg_wrapper *msgs = (struct msg_wrapper *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct msg_wrapper) * MSGS_PER_BLOCK);
|
||||
for(n = 1; n < MSGS_PER_BLOCK; ++n)
|
||||
SLIST_INSERT_HEAD(&free_msgs, &msgs[n], entry);
|
||||
msg = &msgs[0];
|
||||
}else
|
||||
SLIST_REMOVE_HEAD(&free_msgs, entry);
|
||||
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg->lin_msg = lin_msg;
|
||||
|
||||
msg->win_msg.m_pData = msg->lin_msg->m_pData;
|
||||
msg->win_msg.m_cbSize = msg->lin_msg->m_cbSize;
|
||||
msg->win_msg.m_conn = msg->lin_msg->m_conn;
|
||||
msg->win_msg.m_identityPeer = msg->lin_msg->m_identityPeer;
|
||||
msg->win_msg.m_nConnUserData = msg->lin_msg->m_nConnUserData;
|
||||
msg->win_msg.m_usecTimeReceived= msg->lin_msg->m_usecTimeReceived;
|
||||
msg->win_msg.m_nMessageNumber = msg->lin_msg->m_nMessageNumber;
|
||||
msg->win_msg.m_pfnFreeData = (void*)win_FreeData;
|
||||
msg->win_msg.m_pfnRelease = (void*)win_Release;
|
||||
msg->win_msg.m_nChannel = msg->lin_msg->m_nChannel;
|
||||
msg->win_msg.m_nFlags = msg->lin_msg->m_nFlags;
|
||||
msg->win_msg.m_nUserData = msg->lin_msg->m_nUserData;
|
||||
msg->win_msg.m_idxLane = msg->lin_msg->m_idxLane;
|
||||
msg->win_msg._pad1__ = msg->lin_msg->_pad1__;
|
||||
|
||||
msg->orig_FreeData = msg->lin_msg->m_pfnFreeData;
|
||||
msg->lin_msg->m_pfnFreeData = lin_FreeData;
|
||||
/* ! store the wrapper here and restore the original pointer from win_msg before calling orig_FreeData */
|
||||
msg->lin_msg->m_pData = msg;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_153a(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_153a **w, int max_messages)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n_messages > 0)
|
||||
TRACE("%u %p %p\n", n_messages, l, w);
|
||||
|
||||
for(i = 0; i < n_messages; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
msg = clone_msg(l[i]);
|
||||
|
||||
w[i] = &msg->win_msg;
|
||||
|
||||
TRACE("done with %u, returned wrapper %p\n", i, msg);
|
||||
}
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets012_ReceiveMessagesOnConnection(
|
||||
void *linux_side, HSteamNetConnection hConn,
|
||||
winSteamNetworkingMessage_t_153a **ppOutMessages, int nMaxMessages)
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection(hConn, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_153a(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -166,7 +55,7 @@ int cppISteamNetworkingSockets_SteamNetworkingSockets012_ReceiveMessagesOnPollGr
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnPollGroup(hPollGroup, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_153a(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -188,23 +77,7 @@ void cppISteamNetworkingSockets_SteamNetworkingSockets012_SendMessages(
|
||||
while(nMessages)
|
||||
{
|
||||
for(i = 0; i < nMessages && i < MAX_SEND_MESSAGES; ++i)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(pMessages[i], struct msg_wrapper, win_msg);
|
||||
lin_msgs[i] = msg->lin_msg;
|
||||
|
||||
lin_msgs[i]->m_pData = msg->win_msg.m_pData;
|
||||
lin_msgs[i]->m_cbSize = msg->win_msg.m_cbSize;
|
||||
lin_msgs[i]->m_conn = msg->win_msg.m_conn;
|
||||
lin_msgs[i]->m_identityPeer = msg->win_msg.m_identityPeer;
|
||||
lin_msgs[i]->m_nConnUserData = msg->win_msg.m_nConnUserData;
|
||||
lin_msgs[i]->m_usecTimeReceived= msg->win_msg.m_usecTimeReceived;
|
||||
lin_msgs[i]->m_nMessageNumber = msg->win_msg.m_nMessageNumber;
|
||||
lin_msgs[i]->m_nChannel = msg->win_msg.m_nChannel;
|
||||
lin_msgs[i]->m_nFlags = msg->win_msg.m_nFlags;
|
||||
lin_msgs[i]->m_nUserData = msg->win_msg.m_nUserData;
|
||||
lin_msgs[i]->m_idxLane = msg->win_msg.m_idxLane;
|
||||
lin_msgs[i]->_pad1__ = msg->win_msg._pad1__;
|
||||
}
|
||||
lin_msgs[i] = (SteamNetworkingMessage_t *)network_message_win_to_lin(pMessages[i]);
|
||||
|
||||
((ISteamNetworkingSockets*)linux_side)->SendMessages(i, lin_msgs, pOutMessageNumberOrResult);
|
||||
|
||||
@ -233,7 +106,7 @@ int cppISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001_ReceiveMessages
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingFakeUDPPort*)linux_side)->ReceiveMessages(lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_153a(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -324,12 +197,9 @@ bool cppISteamNetworkingUtils_SteamNetworkingUtils004_SetConfigValue(void *linux
|
||||
SteamNetworkingMessage_t *cppISteamNetworkingUtils_SteamNetworkingUtils004_AllocateMessage(
|
||||
void *linux_side, int cbAllocateBuffer)
|
||||
{
|
||||
struct msg_wrapper *msg;
|
||||
SteamNetworkingMessage_t *retval = ((ISteamNetworkingUtils*)linux_side)->AllocateMessage(cbAllocateBuffer);
|
||||
|
||||
msg = clone_msg(retval);
|
||||
|
||||
return (SteamNetworkingMessage_t*)&msg->win_msg;
|
||||
return (SteamNetworkingMessage_t *)network_message_lin_to_win(retval);
|
||||
}
|
||||
|
||||
const char * cppISteamInput_SteamInput006_GetGlyphPNGForActionOrigin(void *linux_side, EInputActionOrigin eOrigin, ESteamInputGlyphSize eSize, uint32 unFlags)
|
||||
|
168
lsteamclient/steamclient_manual_common.cpp
Normal file
168
lsteamclient/steamclient_manual_common.cpp
Normal file
@ -0,0 +1,168 @@
|
||||
extern "C" {
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
||||
}
|
||||
|
||||
#include "steam_defs.h"
|
||||
#pragma push_macro("__cdecl")
|
||||
#undef __cdecl
|
||||
#include "steamworks_sdk_153a/steam_api.h"
|
||||
#include "steamworks_sdk_153a/steamnetworkingtypes.h"
|
||||
|
||||
#pragma pop_macro("__cdecl")
|
||||
#include "steamclient_private.h"
|
||||
|
||||
extern "C" {
|
||||
#define SDKVER_153a
|
||||
#include "struct_converters.h"
|
||||
#include "cb_converters.h"
|
||||
#include "win_constructors.h"
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
#define SDK_VERSION 1531
|
||||
#include "steamclient_manual_common.h"
|
||||
|
||||
struct msg_wrapper {
|
||||
struct winSteamNetworkingMessage_t_153a win_msg;
|
||||
struct SteamNetworkingMessage_t *lin_msg;
|
||||
|
||||
void (*orig_FreeData)(SteamNetworkingMessage_t *);
|
||||
|
||||
SLIST_ENTRY(msg_wrapper) entry;
|
||||
};
|
||||
|
||||
/***** manual struct converter for SteamNetworkingMessage_t *****/
|
||||
|
||||
static SLIST_HEAD(free_msgs_head, msg_wrapper) free_msgs = SLIST_HEAD_INITIALIZER(free_msgs);
|
||||
static CRITICAL_SECTION free_msgs_lock = { NULL, -1, 0, 0, 0, 0 };
|
||||
|
||||
static void __attribute__((ms_abi)) win_FreeData(struct winSteamNetworkingMessage_t_153a *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->orig_FreeData)
|
||||
{
|
||||
msg->lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
msg->orig_FreeData(msg->lin_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((ms_abi)) win_Release(struct winSteamNetworkingMessage_t_153a *win_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
TRACE("%p\n", msg);
|
||||
msg->lin_msg->m_pfnRelease(msg->lin_msg);
|
||||
msg->lin_msg = NULL;
|
||||
msg->orig_FreeData = NULL;
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
SLIST_INSERT_HEAD(&free_msgs, msg, entry);
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
}
|
||||
|
||||
static void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
{
|
||||
struct msg_wrapper *msg = (struct msg_wrapper *)lin_msg->m_pData; /* ! see assignment, below */
|
||||
TRACE("%p\n", msg);
|
||||
if(msg->win_msg.m_pfnFreeData)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_153a *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
void *network_message_lin_to_win_(void *msg_, unsigned int version)
|
||||
{
|
||||
struct SteamNetworkingMessage_t *lin_msg = (struct SteamNetworkingMessage_t *)msg_;
|
||||
struct msg_wrapper *msg;
|
||||
|
||||
EnterCriticalSection(&free_msgs_lock);
|
||||
|
||||
msg = SLIST_FIRST(&free_msgs);
|
||||
|
||||
if(!msg){
|
||||
int n;
|
||||
/* allocs can be pricey, so alloc in blocks */
|
||||
#define MSGS_PER_BLOCK 16
|
||||
struct msg_wrapper *msgs = (struct msg_wrapper *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct msg_wrapper) * MSGS_PER_BLOCK);
|
||||
for(n = 1; n < MSGS_PER_BLOCK; ++n)
|
||||
SLIST_INSERT_HEAD(&free_msgs, &msgs[n], entry);
|
||||
msg = &msgs[0];
|
||||
}else
|
||||
SLIST_REMOVE_HEAD(&free_msgs, entry);
|
||||
|
||||
LeaveCriticalSection(&free_msgs_lock);
|
||||
|
||||
TRACE("lin_msg %p, msg %p.\n", lin_msg, msg);
|
||||
|
||||
msg->lin_msg = lin_msg;
|
||||
|
||||
msg->win_msg.m_pData = msg->lin_msg->m_pData;
|
||||
msg->win_msg.m_cbSize = msg->lin_msg->m_cbSize;
|
||||
msg->win_msg.m_conn = msg->lin_msg->m_conn;
|
||||
msg->win_msg.m_identityPeer = msg->lin_msg->m_identityPeer;
|
||||
msg->win_msg.m_nConnUserData = msg->lin_msg->m_nConnUserData;
|
||||
msg->win_msg.m_usecTimeReceived= msg->lin_msg->m_usecTimeReceived;
|
||||
msg->win_msg.m_nMessageNumber = msg->lin_msg->m_nMessageNumber;
|
||||
msg->win_msg.m_pfnFreeData = (void*)win_FreeData;
|
||||
msg->win_msg.m_pfnRelease = (void*)win_Release;
|
||||
msg->win_msg.m_nChannel = msg->lin_msg->m_nChannel;
|
||||
if (version >= 1470)
|
||||
{
|
||||
msg->win_msg.m_nFlags = msg->lin_msg->m_nFlags;
|
||||
msg->win_msg.m_nUserData = msg->lin_msg->m_nUserData;
|
||||
}
|
||||
if (version >= 1530)
|
||||
msg->win_msg.m_idxLane = msg->lin_msg->m_idxLane;
|
||||
|
||||
msg->orig_FreeData = msg->lin_msg->m_pfnFreeData;
|
||||
msg->lin_msg->m_pfnFreeData = lin_FreeData;
|
||||
/* ! store the wrapper here and restore the original pointer from win_msg before calling orig_FreeData */
|
||||
msg->lin_msg->m_pData = msg;
|
||||
|
||||
return &msg->win_msg;
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_(int n_messages, void **l, void **w, int max_messages, int version)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n_messages > 0)
|
||||
TRACE("%u %p %p\n", n_messages, l, w);
|
||||
|
||||
for(i = 0; i < n_messages; ++i)
|
||||
w[i] = network_message_lin_to_win_(l[i], version);
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
|
||||
void *network_message_win_to_lin_(void *win_msg, unsigned int version)
|
||||
{
|
||||
struct msg_wrapper *msg = CONTAINING_RECORD(win_msg, struct msg_wrapper, win_msg);
|
||||
SteamNetworkingMessage_t *lin_msg = msg->lin_msg;
|
||||
|
||||
TRACE("msg %p, lin_msg %p.\n", msg, lin_msg);
|
||||
|
||||
lin_msg->m_pData = msg->win_msg.m_pData;
|
||||
lin_msg->m_cbSize = msg->win_msg.m_cbSize;
|
||||
lin_msg->m_conn = msg->win_msg.m_conn;
|
||||
lin_msg->m_identityPeer = msg->win_msg.m_identityPeer;
|
||||
lin_msg->m_nConnUserData = msg->win_msg.m_nConnUserData;
|
||||
lin_msg->m_usecTimeReceived= msg->win_msg.m_usecTimeReceived;
|
||||
lin_msg->m_nMessageNumber = msg->win_msg.m_nMessageNumber;
|
||||
lin_msg->m_nChannel = msg->win_msg.m_nChannel;
|
||||
if (version >= 1470)
|
||||
{
|
||||
lin_msg->m_nFlags = msg->win_msg.m_nFlags;
|
||||
lin_msg->m_nUserData = msg->win_msg.m_nUserData;
|
||||
}
|
||||
if (version >= 1530)
|
||||
lin_msg->m_idxLane = msg->win_msg.m_idxLane;
|
||||
|
||||
return lin_msg;
|
||||
}
|
||||
|
||||
} /* extern "C" { */
|
19
lsteamclient/steamclient_manual_common.h
Normal file
19
lsteamclient/steamclient_manual_common.h
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef SDK_VERSION
|
||||
#error "SDK_VERSION is not defined"
|
||||
#endif
|
||||
|
||||
/* Once new steamclient_manual_...cpp is added structures in steamclient_manual_common.cpp
|
||||
* (currently SteamNetworkingMessage_t) must be checked for the compatibility with the new version. */
|
||||
C_ASSERT(SDK_VERSION <= 1531);
|
||||
|
||||
/* Returns Windows version of SteamNetworkingMessage_t */
|
||||
#define network_message_lin_to_win(m) network_message_lin_to_win_(m, SDK_VERSION)
|
||||
void *network_message_lin_to_win_(void *lin_msg, unsigned int version);
|
||||
|
||||
/* Returns Linux version of SteamNetworkingMessage_t */
|
||||
#define network_message_win_to_lin(m) network_message_win_to_lin_(m, SDK_VERSION)
|
||||
void *network_message_win_to_lin_(void *win_msg, unsigned int version);
|
||||
|
||||
#define lin_to_win_struct_SteamNetworkingMessage_t(a, b, c, d) lin_to_win_struct_SteamNetworkingMessage_t_(a, (void **)(b), (void **)(c), d, SDK_VERSION)
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_(int n_messages, void **l, void **w, int max_messages, int version);
|
Loading…
Reference in New Issue
Block a user