From 6b9ebc3ccb2e81101f2480e71b0496d938f20c4b Mon Sep 17 00:00:00 2001 From: Alexander Pavlov Date: Thu, 7 Apr 2016 06:31:08 +0300 Subject: [PATCH] Update GameAgent for Linuxport. --- Sources/Engine/GameAgent/GameAgent.cpp | 35 ++++++++++++++++++++++++-- Sources/Engine/GameAgent/GameAgent.h | 8 +++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Sources/Engine/GameAgent/GameAgent.cpp b/Sources/Engine/GameAgent/GameAgent.cpp index 999ff64..76bf218 100644 --- a/Sources/Engine/GameAgent/GameAgent.cpp +++ b/Sources/Engine/GameAgent/GameAgent.cpp @@ -34,6 +34,7 @@ typedef int socklen_t; #else #include #include +#include #include #include #include @@ -1029,7 +1030,28 @@ extern void GameAgent_EnumUpdate(void) } } else { #ifndef PLATFORM_WIN32 - STUBBED("write me"); + //STUBBED("write me"); + /* MSLegacy LinuxPort */ + if(_bActivated) { + pthread_t _hThread; + int _iThreadId; + + _iThreadId = pthread_create(&_hThread, NULL, _MS_Thread, NULL); + if (_iThreadId == 0) { + pthread_detach(_hThread); + } + _bActivated = FALSE; + } + if(_bActivatedLocal) { + pthread_t _hThread; + int _iThreadId; + + _iThreadId = pthread_create(&_hThread, NULL, _LocalNet_Thread, NULL); + if (_iThreadId == 0) { + pthread_detach(_hThread); + } + _bActivatedLocal = FALSE; + } #else /* MSLegacy */ if(_bActivated) { @@ -1068,6 +1090,10 @@ extern void GameAgent_EnumCancel(void) #ifdef PLATFORM_WIN32 DWORD WINAPI _MS_Thread(LPVOID lpParam) { +#else +void* _MS_Thread(void *arg) { +#endif + SOCKET _sockudp = NULL; struct _sIPPort { UBYTE bFirst; @@ -1266,7 +1292,12 @@ DWORD WINAPI _MS_Thread(LPVOID lpParam) { return 0; } +#ifdef PLATFORM_WIN32 DWORD WINAPI _LocalNet_Thread(LPVOID lpParam) { +#else +void* _LocalNet_Thread(void *arg) { +#endif + SOCKET _sockudp = NULL; struct _sIPPort { UBYTE bFirst; @@ -1477,5 +1508,5 @@ DWORD WINAPI _LocalNet_Thread(LPVOID lpParam) { WSACleanup(); return 0; } -#endif + diff --git a/Sources/Engine/GameAgent/GameAgent.h b/Sources/Engine/GameAgent/GameAgent.h index 835e49a..67c1978 100644 --- a/Sources/Engine/GameAgent/GameAgent.h +++ b/Sources/Engine/GameAgent/GameAgent.h @@ -38,10 +38,16 @@ extern void GameAgent_EnumTrigger(BOOL bInternet); extern void GameAgent_EnumUpdate(void); /// Cancel the GameAgent serverlist enumeration. extern void GameAgent_EnumCancel(void); -/// + +#ifdef PLATFORM_WIN32 DWORD WINAPI _MS_Thread(LPVOID lpParam); /// DWORD WINAPI _LocalNet_Thread(LPVOID lpParam); +#else +void* _MS_Thread(void *arg); +/// +void* _LocalNet_Thread(void *arg); +#endif /// Server request structure. Primarily used for getting server pings. class CServerRequest {