* initial wiki

* reduce code in linux build script

* make steamnetworkingsockets.cpp compile (Win + Linux)
This commit is contained in:
otavepto 2024-01-26 21:31:26 +02:00
parent 8e5c752183
commit 1a5998d13b
5 changed files with 348 additions and 219 deletions

View File

@ -22,7 +22,9 @@ You can find the original README here: [README.md](./z_original_repo_files/READM
---
## How to use the emu
You can find instructions here: [README.release.md](./post_build/README.release.md)
You can find instructions here: [README.release.md](./post_build/README.release.md)
You can helper scripts and tools mentioned here in this wiki: https://github.com/otavepto/gbe_fork/wiki/Emu-helpers
---
---
@ -159,8 +161,13 @@ Arguments you can pass to this script:
>>>>>>>>> ___
* `-tool-itf` prevent building the tool `find_interfaces`:
* `-tool-lobby`: prevent building the tool `lobby_connect`:
* `-tool-itf` prevent building the tool `find_interfaces`
* `-tool-lobby`: prevent building the tool `lobby_connect`
>>>>>>>>> ___
* `+lib-netsockets-32` *(experimental)*: build a standalone networking sockets library (32-bit)
* `+lib-netsockets-64` *(experimental)*: build a standalone networking sockets library (64-bit)
<br/>
@ -200,10 +207,15 @@ Arguments you can pass to this script:
>>>>>>>>> ___
* `-tool-itf-32`: prevent building the tool 32-bit `find_interfaces`:
* `-tool-itf-64`: prevent building the tool 64-bit `find_interfaces`:
* `-tool-lobby-32`: prevent building the tool 32-bit `lobby_connect`:
* `-tool-lobby-64`: prevent building the tool 64-bit `lobby_connect`:
* `-tool-itf-32`: prevent building the tool 32-bit `find_interfaces`
* `-tool-itf-64`: prevent building the tool 64-bit `find_interfaces`
* `-tool-lobby-32`: prevent building the tool 32-bit `lobby_connect`
* `-tool-lobby-64`: prevent building the tool 64-bit `lobby_connect`
>>>>>>>>> ___
* `+lib-netsockets-32` *(experimental)*: build a standalone networking sockets library (32-bit)
* `+lib-netsockets-64` *(experimental)*: build a standalone networking sockets library (64-bit)
---

View File

@ -27,6 +27,9 @@ BUILD_TOOL_FIND_ITFS64=1
BUILD_TOOL_LOBBY32=1
BUILD_TOOL_LOBBY64=1
BUILD_LIB_NET_SOCKETS_32=0
BUILD_LIB_NET_SOCKETS_64=0
# < 0: deduce, > 1: force
PARALLEL_THREADS_OVERRIDE=-1
@ -65,6 +68,10 @@ for (( i=1; i<=$#; i++ )); do
BUILD_TOOL_LOBBY32=0
elif [[ "$var" = "-tool-lobby-64" ]]; then
BUILD_TOOL_LOBBY64=0
elif [[ "$var" = "+lib-netsockets-32" ]]; then
BUILD_LIB_NET_SOCKETS_32=1
elif [[ "$var" = "+lib-netsockets-64" ]]; then
BUILD_LIB_NET_SOCKETS_64=1
elif [[ "$var" = "-verbose" ]]; then
VERBOSE=1
elif [[ "$var" = "clean" ]]; then
@ -358,6 +365,10 @@ function build_for () {
return 1;
}
local out_dir="${out_filepath%/*}"
[[ "$out_dir" = "$out_filepath" ]] && out_dir='.'
mkdir -p "$out_dir"
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/developer_guide/gcc-using-libraries#gcc-using-libraries_using-both-static-dynamic-library-gcc
# https://linux.die.net/man/1/ld
if [[ $VERBOSE = 1 ]]; then
@ -406,8 +417,6 @@ echo; echo;
if [[ "$BUILD_LIB32" = "1" ]]; then
echo // building shared lib libsteam_api.so - 32
[[ -d "$build_root_32" ]] || mkdir -p "$build_root_32"
all_src_files=(
"${release_src[@]}"
"controller/*.c"
@ -418,8 +427,6 @@ fi
if [[ "$BUILD_CLIENT32" = "1" ]]; then
echo // building shared lib steamclient.so - 32
[[ -d "$build_root_32" ]] || mkdir -p "$build_root_32"
all_src_files=(
"${release_src[@]}"
"controller/*.c"
@ -430,8 +437,6 @@ fi
if [[ "$BUILD_TOOL_LOBBY32" = "1" ]]; then
echo // building executable lobby_connect_x32 - 32
[[ -d "$build_root_tools/lobby_connect" ]] || mkdir -p "$build_root_tools/lobby_connect"
all_src_files=(
"${release_src[@]}"
"$tools_dir/lobby_connect/lobby_connect.cpp"
@ -442,8 +447,6 @@ fi
if [[ "$BUILD_TOOL_FIND_ITFS32" = "1" ]]; then
echo // building executable generate_interfaces_file_x32 - 32
[[ -d "$build_root_tools/find_interfaces" ]] || mkdir -p "$build_root_tools/find_interfaces"
all_src_files=(
"$tools_dir/generate_interfaces/generate_interfaces.cpp"
)
@ -451,6 +454,15 @@ if [[ "$BUILD_TOOL_FIND_ITFS32" = "1" ]]; then
last_code=$((last_code + $?))
fi
if [[ "$BUILD_LIB_NET_SOCKETS_32" = "1" ]]; then
echo // building shared lib steamnetworkingsockets.so - 32
all_src_files=(
"networking_sockets_lib/steamnetworkingsockets.cpp"
)
build_for 1 0 "$build_root_dir/networking_sockets_lib/steamnetworkingsockets.so" '' all_src_files
last_code=$((last_code + $?))
fi
### x64 build
cleanup
@ -464,8 +476,6 @@ echo; echo;
if [[ "$BUILD_LIB64" = "1" ]]; then
echo // building shared lib libsteam_api.so - 64
[[ -d "$build_root_64" ]] || mkdir -p "$build_root_64"
all_src_files=(
"${release_src[@]}"
"controller/*.c"
@ -476,8 +486,6 @@ fi
if [[ "$BUILD_CLIENT64" = "1" ]]; then
echo // building shared lib steamclient.so - 64
[[ -d "$build_root_64" ]] || mkdir -p "$build_root_64"
all_src_files=(
"${release_src[@]}"
"controller/*.c"
@ -488,8 +496,6 @@ fi
if [[ "$BUILD_TOOL_LOBBY64" = "1" ]]; then
echo // building executable lobby_connect_x64 - 64
[[ -d "$build_root_tools/lobby_connect" ]] || mkdir -p "$build_root_tools/lobby_connect"
all_src_files=(
"${release_src[@]}"
"$tools_dir/lobby_connect/lobby_connect.cpp"
@ -500,8 +506,6 @@ fi
if [[ "$BUILD_TOOL_FIND_ITFS64" = "1" ]]; then
echo // building executable generate_interfaces_file_x64 - 64
[[ -d "$build_root_tools/find_interfaces" ]] || mkdir -p "$build_root_tools/find_interfaces"
all_src_files=(
"$tools_dir/generate_interfaces/generate_interfaces.cpp"
)
@ -509,6 +513,15 @@ if [[ "$BUILD_TOOL_FIND_ITFS64" = "1" ]]; then
last_code=$((last_code + $?))
fi
if [[ "$BUILD_LIB_NET_SOCKETS_64" = "1" ]]; then
echo // building shared lib steamnetworkingsockets64.so - 64
all_src_files=(
"networking_sockets_lib/steamnetworkingsockets.cpp"
)
build_for 0 0 "$build_root_dir/networking_sockets_lib/steamnetworkingsockets64.so" '' all_src_files
last_code=$((last_code + $?))
fi
# cleanup
cleanup

View File

@ -36,6 +36,9 @@ set /a BUILD_EXPCLIENT_EXTRA_64=0
set /a BUILD_TOOL_FIND_ITFS=1
set /a BUILD_TOOL_LOBBY=1
set /a BUILD_LIB_NET_SOCKETS_32=0
set /a BUILD_LIB_NET_SOCKETS_64=0
:: < 0: deduce, > 1: force
set /a PARALLEL_THREADS_OVERRIDE=-1
@ -78,6 +81,10 @@ set /a VERBOSE=0
set /a BUILD_TOOL_FIND_ITFS=0
) else if "%~1"=="-tool-lobby" (
set /a BUILD_TOOL_LOBBY=0
) else if "%~1"=="+lib-netsockets-32" (
set /a BUILD_LIB_NET_SOCKETS_32=1
) else if "%~1"=="+lib-netsockets-64" (
set /a BUILD_LIB_NET_SOCKETS_64=1
) else if "%~1"=="-j" (
call :get_parallel_threads_count %~2 || (
call :err_msg "Invalid arg after -j, expected a number"
@ -371,6 +378,14 @@ if %BUILD_TOOL_LOBBY% equ 1 (
echo: & echo:
)
:: networking sockets lib (x32)
if %BUILD_LIB_NET_SOCKETS_32% equ 1 (
call :compile_networking_sockets_lib_32 || (
set /a last_code+=1
)
echo: & echo:
)
endlocal & set /a last_code=%last_code%
@ -466,6 +481,14 @@ if %BUILD_EXPCLIENT_EXTRA_64% equ 1 (
echo: & echo:
)
:: networking sockets lib (x64)
if %BUILD_LIB_NET_SOCKETS_64% equ 1 (
call :compile_networking_sockets_lib_64 || (
set /a last_code+=1
)
echo: & echo:
)
endlocal & set /a last_code=%last_code%
@ -609,6 +632,18 @@ endlocal & exit /b %_exit%
)
endlocal & exit /b %_exit%
:compile_networking_sockets_lib_32
setlocal
echo // building library steamnetworkingsockets.dll - 32
set src_files="networking_sockets_lib\steamnetworkingsockets.cpp"
call :build_for 1 0 "%build_root_dir%\networking_sockets_lib\steamnetworkingsockets.dll" src_files
set /a _exit=%errorlevel%
if %_exit% equ 0 (
call :change_dos_stub 1 "%build_root_dir%\networking_sockets_lib\steamnetworkingsockets.dll"
call "%signer_tool%" "%build_root_dir%\networking_sockets_lib\steamnetworkingsockets.dll"
)
endlocal & exit /b %_exit%
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: x64
@ -689,6 +724,18 @@ endlocal & exit /b %_exit%
)
endlocal & exit /b %_exit%
:compile_networking_sockets_lib_64
setlocal
echo // building library steamnetworkingsockets64.dll - 64
set src_files="networking_sockets_lib\steamnetworkingsockets.cpp"
call :build_for 0 0 "%build_root_dir%\networking_sockets_lib\steamnetworkingsockets64.dll" src_files
set /a _exit=%errorlevel%
if %_exit% equ 0 (
call :change_dos_stub 0 "%build_root_dir%\networking_sockets_lib\steamnetworkingsockets64.dll"
call "%signer_tool%" "%build_root_dir%\networking_sockets_lib\steamnetworkingsockets64.dll"
)
endlocal & exit /b %_exit%
:err_msg

View File

@ -0,0 +1,253 @@
#include <stdio.h>
#include <chrono>
#define STEAMNETWORKINGSOCKETS_STANDALONELIB
#define STEAMNETWORKINGSOCKETS_STEAMAPI
#define STEAMNETWORKINGSOCKETS_FOREXPORT
#define STEAM_API_EXPORTS
#include "steam/steam_gameserver.h"
const std::chrono::time_point<std::chrono::high_resolution_clock> startup_counter = std::chrono::high_resolution_clock::now();
const std::chrono::time_point<std::chrono::system_clock> startup_time = std::chrono::system_clock::now();
#ifndef EMU_RELEASE_BUILD
// we need this for printf specifiers for intptr_t such as PRIdPTR
#include <inttypes.h>
#if defined(WIN32) || defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#define PRINT_DEBUG(a, ...) do { \
auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now(); \
auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter; \
auto __prnt_dbg_micro = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::micro>>(__prnt_dbg_duration); \
auto __prnt_dbg_ms = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::milli>>(__prnt_dbg_duration); \
auto __prnt_dbg_f = fopen("NETWORKING_SOCKET_LIB_LOG.txt", "a"); \
fprintf(__prnt_dbg_f, "[%llu ms, %llu us] [tid %lu] " a, __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), GetCurrentThreadId(), __VA_ARGS__); \
fclose(__prnt_dbg_f); \
} while (0)
#else
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif // _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#define PRINT_DEBUG(a, ...) do { \
auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now(); \
auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter; \
auto __prnt_dbg_micro = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::micro>>(__prnt_dbg_duration); \
auto __prnt_dbg_ms = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::milli>>(__prnt_dbg_duration); \
auto __prnt_dbg_f = fopen("NETWORKING_SOCKET_LIB_LOG.txt", "a"); \
fprintf(__prnt_dbg_f, "[%llu ms, %llu us] [tid %ld] " a, __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), syscall(SYS_gettid), ##__VA_ARGS__); \
fclose(__prnt_dbg_f); \
} while (0)
#endif
#else // EMU_RELEASE_BUILD
#define PRINT_DEBUG(...)
#endif // EMU_RELEASE_BUILD
#if defined(WIN32) || defined(_WIN32)
#define NETWORKING_SOCKET_LIB_API extern "C" __declspec( dllexport )
#else // !WIN32
#define NETWORKING_SOCKET_LIB_API extern "C" __attribute__ ((visibility("default")))
#endif
/*
extern "C" __declspec( dllexport ) void *CreateInterface( const char *pName, int *pReturnCode )
{
//PRINT_DEBUG("steamclient CreateInterface %s\n", pName);
HMODULE steam_api = LoadLibraryA(DLL_NAME);
void *(__stdcall* create_interface)(const char*) = (void * (__stdcall *)(const char*))GetProcAddress(steam_api, "SteamInternal_CreateInterface");
return create_interface(pName);
}
*/
class ISteamNetworkingUtilsDll
{
virtual SteamNetworkingMicroseconds GetLocalTimestamp() = 0;
//not sure if these are the correct functions
virtual bool CheckPingDataUpToDate( float flMaxAgeSeconds ) = 0;
virtual void a() = 0;
virtual void b() = 0;
virtual void c() = 0;
virtual void d() = 0;
virtual void e() = 0;
virtual void f() = 0;
virtual void g() = 0;
virtual void h() = 0;
virtual void i() = 0;
virtual void j() = 0;
};
class ISteamNetworkingP2P
{
virtual void a() = 0;
virtual void b() = 0;
virtual void c() = 0;
virtual void d() = 0;
virtual void e() = 0;
virtual void f() = 0;
virtual void g() = 0;
virtual void h() = 0;
virtual void i() = 0;
virtual void j() = 0;
};
template <class steam_networkingutils_class>
class Networking_Utils_DLL : public steam_networkingutils_class
{
public:
ISteamNetworkingUtils *networking_utils;
Networking_Utils_DLL(ISteamNetworkingUtils *networking_utils)
{
this->networking_utils = networking_utils;
}
SteamNetworkingMicroseconds GetLocalTimestamp() { return networking_utils->GetLocalTimestamp(); }
bool CheckPingDataUpToDate( float flMaxAgeSeconds ) { return networking_utils->CheckPingDataUpToDate(flMaxAgeSeconds); }
void a() { PRINT_DEBUG("Networking_Utils_DLL::a\n"); }
void b() { PRINT_DEBUG("Networking_Utils_DLL::b\n"); }
void c() { PRINT_DEBUG("Networking_Utils_DLL::c\n"); }
void d() { PRINT_DEBUG("Networking_Utils_DLL::d\n"); }
void e() { PRINT_DEBUG("Networking_Utils_DLL::e\n"); }
void f() { PRINT_DEBUG("Networking_Utils_DLL::f\n"); }
void g() { PRINT_DEBUG("Networking_Utils_DLL::g\n"); }
void h() { PRINT_DEBUG("Networking_Utils_DLL::h\n"); }
void i() { PRINT_DEBUG("Networking_Utils_DLL::i\n"); }
void j() { PRINT_DEBUG("Networking_Utils_DLL::j\n"); }
};
template <class steam_networkingp2p_class>
class Networking_P2P_DLL : public steam_networkingp2p_class
{
public:
void a() { PRINT_DEBUG("Networking_P2P_DLL::a\n"); }
void b() { PRINT_DEBUG("Networking_P2P_DLL::b\n"); }
void c() { PRINT_DEBUG("Networking_P2P_DLL::c\n"); }
void d() { PRINT_DEBUG("Networking_P2P_DLL::d\n"); }
void e() { PRINT_DEBUG("Networking_P2P_DLL::e\n"); }
void f() { PRINT_DEBUG("Networking_P2P_DLL::f\n"); }
void g() { PRINT_DEBUG("Networking_P2P_DLL::g\n"); }
void h() { PRINT_DEBUG("Networking_P2P_DLL::h\n"); }
void i() { PRINT_DEBUG("Networking_P2P_DLL::i\n"); }
void j() { PRINT_DEBUG("Networking_P2P_DLL::j\n"); }
};
static void *networking_sockets_gameserver;
static void *networking_sockets;
static void *networking_utils;
static void *networking_p2p;
static void *networking_p2p_gameserver;
NETWORKING_SOCKET_LIB_API class ISteamNetworkingSockets *SteamNetworkingSockets()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamNetworkingSockets\n");
return (class ISteamNetworkingSockets *)networking_sockets;
}
NETWORKING_SOCKET_LIB_API class ISteamNetworkingSockets *SteamNetworkingSockets_LibV12()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamNetworkingSockets_LibV12\n");
return SteamNetworkingSockets();
}
NETWORKING_SOCKET_LIB_API class ISteamNetworkingSockets *SteamGameServerNetworkingSockets()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamGameServerNetworkingSockets\n");
return (class ISteamNetworkingSockets *)networking_sockets_gameserver;
}
NETWORKING_SOCKET_LIB_API class ISteamNetworkingSockets *SteamGameServerNetworkingSockets_LibV12()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamGameServerNetworkingSockets_LibV12\n");
return SteamGameServerNetworkingSockets();
}
const int k_cchMaxSteamDatagramErrMsg = 1024;
typedef char SteamDatagramErrMsg[ k_cchMaxSteamDatagramErrMsg ];
typedef void * ( S_CALLTYPE *FSteamInternal_CreateInterface )( const char *);
NETWORKING_SOCKET_LIB_API bool SteamDatagramClient_Init_InternalV6( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamDatagramClient_Init_InternalV6 %u %u\n", hSteamUser, hSteamPipe);
ISteamClient *client = (ISteamClient *)fnCreateInterface(STEAMCLIENT_INTERFACE_VERSION);
networking_sockets = client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingSockets001");
networking_utils = new Networking_Utils_DLL<ISteamNetworkingUtilsDll>( (ISteamNetworkingUtils *)client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingUtils001") );
networking_p2p = new Networking_P2P_DLL<ISteamNetworkingP2P>();
return true;
}
NETWORKING_SOCKET_LIB_API bool SteamDatagramClient_Init_InternalV9( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamDatagramClient_Init_InternalV9 %u %u\n", hSteamUser, hSteamPipe);
return SteamDatagramClient_Init_InternalV6(errMsg, fnCreateInterface, hSteamUser, hSteamPipe );
}
NETWORKING_SOCKET_LIB_API void SteamDatagramServer_Kill( )
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamDatagramServer_Kill\n");
}
NETWORKING_SOCKET_LIB_API void SteamNetworkingSockets_SetDebugOutputFunction( ESteamNetworkingSocketsDebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc )
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamNetworkingSockets_SetDebugOutputFunction %i\n", eDetailLevel);
if (networking_utils) {
((Networking_Utils_DLL<ISteamNetworkingUtilsDll> *)networking_utils)->networking_utils->SetDebugOutputFunction(eDetailLevel, pfnFunc);
}
}
typedef void ( S_CALLTYPE *FSteamAPI_RegisterCallback)( class CCallbackBase *pCallback, int iCallback );
typedef void ( S_CALLTYPE *FSteamAPI_UnregisterCallback)( class CCallbackBase *pCallback );
typedef void ( S_CALLTYPE *FSteamAPI_RegisterCallResult)( class CCallbackBase *pCallback, SteamAPICall_t hAPICall );
typedef void ( S_CALLTYPE *FSteamAPI_UnregisterCallResult)( class CCallbackBase *pCallback, SteamAPICall_t hAPICall );
NETWORKING_SOCKET_LIB_API void SteamDatagramClient_Internal_SteamAPIKludge( FSteamAPI_RegisterCallback fnRegisterCallback, FSteamAPI_UnregisterCallback fnUnregisterCallback, FSteamAPI_RegisterCallResult fnRegisterCallResult, FSteamAPI_UnregisterCallResult fnUnregisterCallResult )
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamDatagramClient_Internal_SteamAPIKludge\n");
}
NETWORKING_SOCKET_LIB_API void SteamDatagramClient_Kill()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamDatagramClient_Kill\n");
}
NETWORKING_SOCKET_LIB_API bool SteamDatagramServer_Init_Internal( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamDatagramServer_Init_Internal %u %u\n", hSteamUser, hSteamPipe);
ISteamClient *client = (ISteamClient *)fnCreateInterface(STEAMCLIENT_INTERFACE_VERSION);
networking_sockets_gameserver = client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingSockets001");
networking_utils = new Networking_Utils_DLL<ISteamNetworkingUtilsDll>( (ISteamNetworkingUtils *)client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingUtils001"));
return true;
}
NETWORKING_SOCKET_LIB_API class ISteamNetworkingUtils *SteamNetworkingUtils()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamNetworkingUtils\n");
return (class ISteamNetworkingUtils *)networking_utils;
}
NETWORKING_SOCKET_LIB_API void *SteamNetworkingP2P()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamNetworkingP2P\n");
return networking_p2p;
}
NETWORKING_SOCKET_LIB_API void *SteamNetworkingP2PGameServer()
{
PRINT_DEBUG("SteamNetworkingSocketsLib::SteamNetworkingP2PGameServer\n");
return NULL;
}

View File

@ -1,196 +0,0 @@
#include <stdio.h>
#define NETWORKSOCKETS_DLL
#define STEAM_API_EXPORTS
#include "steam/steam_gameserver.h"
#if defined(WIN32) || defined(_WIN32)
#include <Windows.h>
#ifndef EMU_RELEASE_BUILD
#define PRINT_DEBUG(a, ...) do {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, "%u " a, GetCurrentThreadId(), __VA_ARGS__); fclose(t);} while (0)
#endif
#else
#define PATH_SEPARATOR "/"
#ifndef EMU_RELEASE_BUILD
#define PRINT_DEBUG(...) {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, __VA_ARGS__); fclose(t);}
#endif
#endif
//#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__)
#ifdef EMU_RELEASE_BUILD
#define PRINT_DEBUG(...)
#endif
/*
extern "C" __declspec( dllexport ) void *CreateInterface( const char *pName, int *pReturnCode )
{
//PRINT_DEBUG("steamclient CreateInterface %s\n", pName);
HMODULE steam_api = LoadLibraryA(DLL_NAME);
void *(__stdcall* create_interface)(const char*) = (void * (__stdcall *)(const char*))GetProcAddress(steam_api, "SteamInternal_CreateInterface");
return create_interface(pName);
}
*/
class ISteamNetworkingUtilsDll
{
virtual SteamNetworkingMicroseconds GetLocalTimestamp() = 0;
//not sure if these are the correct functions
virtual bool CheckPingDataUpToDate( float flMaxAgeSeconds ) = 0;
virtual void a() = 0;
virtual void b() = 0;
virtual void c() = 0;
virtual void d() = 0;
virtual void e() = 0;
virtual void f() = 0;
virtual void g() = 0;
virtual void h() = 0;
virtual void i() = 0;
virtual void j() = 0;
};
class ISteamNetworkingP2P
{
virtual void a() = 0;
virtual void b() = 0;
virtual void c() = 0;
virtual void d() = 0;
virtual void e() = 0;
virtual void f() = 0;
virtual void g() = 0;
virtual void h() = 0;
virtual void i() = 0;
virtual void j() = 0;
};
template <class steam_networkingutils_class>
class Networking_Utils_DLL : public steam_networkingutils_class
{
public:
ISteamNetworkingUtils *networking_utils;
Networking_Utils_DLL(ISteamNetworkingUtils *networking_utils)
{
this->networking_utils = networking_utils;
}
SteamNetworkingMicroseconds GetLocalTimestamp() { return networking_utils->GetLocalTimestamp(); }
bool CheckPingDataUpToDate( float flMaxAgeSeconds ) { return networking_utils->CheckPingDataUpToDate(flMaxAgeSeconds); }
void a() { PRINT_DEBUG("Networking_Utils_DLL::a\n"); }
void b() { PRINT_DEBUG("Networking_Utils_DLL::b\n"); }
void c() { PRINT_DEBUG("Networking_Utils_DLL::c\n"); }
void d() { PRINT_DEBUG("Networking_Utils_DLL::d\n"); }
void e() { PRINT_DEBUG("Networking_Utils_DLL::e\n"); }
void f() { PRINT_DEBUG("Networking_Utils_DLL::f\n"); }
void g() { PRINT_DEBUG("Networking_Utils_DLL::g\n"); }
void h() { PRINT_DEBUG("Networking_Utils_DLL::h\n"); }
void i() { PRINT_DEBUG("Networking_Utils_DLL::i\n"); }
void j() { PRINT_DEBUG("Networking_Utils_DLL::j\n"); }
};
template <class steam_networkingp2p_class>
class Networking_P2P_DLL : public steam_networkingp2p_class
{
public:
void a() { PRINT_DEBUG("Networking_P2P_DLL::a\n"); }
void b() { PRINT_DEBUG("Networking_P2P_DLL::b\n"); }
void c() { PRINT_DEBUG("Networking_P2P_DLL::c\n"); }
void d() { PRINT_DEBUG("Networking_P2P_DLL::d\n"); }
void e() { PRINT_DEBUG("Networking_P2P_DLL::e\n"); }
void f() { PRINT_DEBUG("Networking_P2P_DLL::f\n"); }
void g() { PRINT_DEBUG("Networking_P2P_DLL::g\n"); }
void h() { PRINT_DEBUG("Networking_P2P_DLL::h\n"); }
void i() { PRINT_DEBUG("Networking_P2P_DLL::i\n"); }
void j() { PRINT_DEBUG("Networking_P2P_DLL::j\n"); }
};
static void *networking_sockets_gameserver;
static void *networking_sockets;
static void *networking_utils;
static void *networking_p2p;
static void *networking_p2p_gameserver;
extern "C" __declspec( dllexport ) void *SteamNetworkingSocketsGameServer()
{
PRINT_DEBUG("SteamNetworkingSocketsGameServer\n");
return networking_sockets_gameserver;
}
extern "C" __declspec( dllexport ) void *SteamNetworkingSockets()
{
PRINT_DEBUG("SteamNetworkingSockets\n");
return networking_sockets;
}
const int k_cchMaxSteamDatagramErrMsg = 1024;
typedef char SteamDatagramErrMsg[ k_cchMaxSteamDatagramErrMsg ];
typedef void * ( S_CALLTYPE *FSteamInternal_CreateInterface )( const char *);
extern "C" __declspec( dllexport ) bool SteamDatagramClient_Init_InternalV6( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
{
PRINT_DEBUG("SteamDatagramClient_Init_InternalV6 %u %u\n", hSteamUser, hSteamPipe);
ISteamClient *client = (ISteamClient *)fnCreateInterface(STEAMCLIENT_INTERFACE_VERSION);
networking_sockets = client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingSockets001");
networking_utils = new Networking_Utils_DLL<ISteamNetworkingUtilsDll>( (ISteamNetworkingUtils *)client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingUtils001") );
networking_p2p = new Networking_P2P_DLL<ISteamNetworkingP2P>();
return true;
}
extern "C" __declspec( dllexport ) bool SteamDatagramClient_Init_InternalV9( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
{
PRINT_DEBUG("SteamDatagramClient_Init_InternalV9 %u %u\n", hSteamUser, hSteamPipe);
return SteamDatagramClient_Init_InternalV6(errMsg, fnCreateInterface, hSteamUser, hSteamPipe );
}
extern "C" __declspec( dllexport ) void SteamDatagramServer_Kill( )
{
PRINT_DEBUG("SteamDatagramServer_Kill\n");
}
extern "C" __declspec( dllexport ) void SteamNetworkingSockets_SetDebugOutputFunction( ESteamNetworkingSocketsDebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc )
{
PRINT_DEBUG("SteamNetworkingSockets_SetDebugOutputFunction %i\n", eDetailLevel);
if (networking_utils) ((Networking_Utils_DLL<ISteamNetworkingUtilsDll> *)networking_utils)->networking_utils->SetDebugOutputFunction(eDetailLevel, pfnFunc);
}
typedef void ( S_CALLTYPE *FSteamAPI_RegisterCallback)( class CCallbackBase *pCallback, int iCallback );
typedef void ( S_CALLTYPE *FSteamAPI_UnregisterCallback)( class CCallbackBase *pCallback );
typedef void ( S_CALLTYPE *FSteamAPI_RegisterCallResult)( class CCallbackBase *pCallback, SteamAPICall_t hAPICall );
typedef void ( S_CALLTYPE *FSteamAPI_UnregisterCallResult)( class CCallbackBase *pCallback, SteamAPICall_t hAPICall );
extern "C" __declspec( dllexport ) void SteamDatagramClient_Internal_SteamAPIKludge( FSteamAPI_RegisterCallback fnRegisterCallback, FSteamAPI_UnregisterCallback fnUnregisterCallback, FSteamAPI_RegisterCallResult fnRegisterCallResult, FSteamAPI_UnregisterCallResult fnUnregisterCallResult )
{
PRINT_DEBUG("SteamDatagramClient_Internal_SteamAPIKludge\n");
}
extern "C" __declspec( dllexport ) void SteamDatagramClient_Kill()
{
PRINT_DEBUG("SteamDatagramClient_Kill\n");
}
extern "C" __declspec( dllexport ) bool SteamDatagramServer_Init_Internal( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
{
PRINT_DEBUG("SteamDatagramServer_Init_Internal %u %u\n", hSteamUser, hSteamPipe);
ISteamClient *client = (ISteamClient *)fnCreateInterface(STEAMCLIENT_INTERFACE_VERSION);
networking_sockets_gameserver = client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingSockets001");
networking_utils = new Networking_Utils_DLL<ISteamNetworkingUtilsDll>( (ISteamNetworkingUtils *)client->GetISteamGenericInterface(hSteamUser, hSteamPipe, "SteamNetworkingUtils001"));
return true;
}
extern "C" __declspec( dllexport ) void *SteamNetworkingUtils()
{
PRINT_DEBUG("SteamNetworkingUtils\n");
return networking_utils;
}
extern "C" __declspec( dllexport ) void *SteamNetworkingP2P()
{
PRINT_DEBUG("SteamNetworkingP2P\n");
return networking_p2p;
}
extern "C" __declspec( dllexport ) void *SteamNetworkingP2PGameServer()
{
PRINT_DEBUG("SteamNetworkingP2PGameServer\n");
return NULL;
}