mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-09 09:16:42 +00:00
fixed windows build
This commit is contained in:
@@ -32,7 +32,11 @@ bool Send(SOCKET TCPSock,std::string Data){
|
||||
}
|
||||
std::string Rcv(SOCKET TCPSock){
|
||||
uint32_t RealSize;
|
||||
int64_t BytesRcv = recv(TCPSock, &RealSize, sizeof(RealSize), 0);
|
||||
#ifdef WIN32
|
||||
int64_t BytesRcv = recv(TCPSock, reinterpret_cast<char*>(&RealSize), sizeof(RealSize), 0);
|
||||
#else
|
||||
int64_t BytesRcv = recv(TCPSock, reinterpret_cast<void*>(&RealSize), sizeof(RealSize), 0);
|
||||
#endif
|
||||
if (BytesRcv != sizeof(RealSize)) {
|
||||
error(std::string(Sec("invalid packet: expected 4, got ")) + std::to_string(BytesRcv));
|
||||
return "";
|
||||
@@ -193,18 +197,18 @@ void Identify(SOCKET TCPSock){
|
||||
// reason MSVC defines __try and __except and libg++ defines
|
||||
// __try and __catch so its all a big mess if we leave this in or undefine
|
||||
// the macros
|
||||
#ifdef WIN32
|
||||
/*#ifdef WIN32
|
||||
__try{
|
||||
#endif // WIN32
|
||||
#endif // WIN32*/
|
||||
Identification(TCPSock,S,Skey);
|
||||
#ifdef WIN32
|
||||
/*#ifdef WIN32
|
||||
}__except(1){
|
||||
if(TCPSock != -1){
|
||||
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||
closesocket(TCPSock);
|
||||
}
|
||||
}
|
||||
#endif // WIN32
|
||||
#endif // WIN32*/
|
||||
|
||||
delete Skey;
|
||||
delete S;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 4/9/2020
|
||||
///
|
||||
#define CURL_STATICLIB
|
||||
#include "Curl/curl.h"
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "CustomAssert.h"
|
||||
#include <iostream>
|
||||
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp){
|
||||
|
||||
@@ -59,6 +59,7 @@ void UpdatePlayers(){
|
||||
SendToAll(nullptr, Packet,true,true);
|
||||
}
|
||||
void OnDisconnect(Client*c,bool kicked){
|
||||
|
||||
Assert(c);
|
||||
info(c->GetName() + Sec(" Connection Terminated"));
|
||||
if(c == nullptr)return;
|
||||
|
||||
@@ -93,14 +93,16 @@ void Parse(Client* c, const std::string& Packet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool STCPRecv(Client* c) {
|
||||
Assert(c);
|
||||
if (c == nullptr)
|
||||
return false;
|
||||
char buf[200];
|
||||
size_t len = 200;
|
||||
#define len 200
|
||||
char buf[len];
|
||||
ZeroMemory(buf, len);
|
||||
int64_t BytesRcv = recv(c->GetTCPSock(), buf, len, 0);
|
||||
#undef len
|
||||
if (BytesRcv == 0) {
|
||||
if (c->GetStatus() > -1)
|
||||
c->SetStatus(-1);
|
||||
|
||||
@@ -41,10 +41,11 @@ void TCPHandle(Client*c,const std::string& data){
|
||||
void TCPRcv(Client*c){
|
||||
Assert(c);
|
||||
if(c == nullptr || c->GetStatus() < 0)return;
|
||||
char buf[4096];
|
||||
size_t len = 4096;
|
||||
#define len 4096
|
||||
char buf[len];
|
||||
ZeroMemory(buf, len);
|
||||
int64_t BytesRcv = recv(c->GetTCPSock(), buf, len,0);
|
||||
#undef len
|
||||
if (BytesRcv == 0){
|
||||
debug(Sec("(TCP) Connection closing..."));
|
||||
if(c->GetStatus() > -1)c->SetStatus(-1);
|
||||
|
||||
@@ -52,10 +52,14 @@ void UDPSend(Client* c, std::string Data) {
|
||||
|
||||
sendOk = sendto(UDPSock, Data.c_str(), len, 0, (sockaddr*)&Addr, AddrSize);
|
||||
#ifdef WIN32
|
||||
if (sendOk != 0) {
|
||||
if (sendOk == -1) {
|
||||
debug(Sec("(UDP) Send Failed Code : ") + std::to_string(WSAGetLastError()));
|
||||
if (c->GetStatus() > -1)
|
||||
c->SetStatus(-1);
|
||||
} else if (sendOk == 0) {
|
||||
debug(Sec("(UDP) sendto returned 0"));
|
||||
if (c->GetStatus() > -1)
|
||||
c->SetStatus(-1);
|
||||
}
|
||||
#else // unix
|
||||
if (sendOk == -1) {
|
||||
|
||||
Reference in New Issue
Block a user