mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-07 16:26:04 +00:00
change __WIN32 to WIN32 (oops)
This commit is contained in:
@@ -158,20 +158,20 @@ 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){
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
|
||||
if(TCPSock != -1){
|
||||
closesocket(TCPSock);
|
||||
}
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
}
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
|
||||
delete Skey;
|
||||
delete S;
|
||||
@@ -179,7 +179,7 @@ void Identify(SOCKET TCPSock){
|
||||
|
||||
void TCPServerMain(){
|
||||
DebugPrintTID();
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(514, &wsaData)){
|
||||
error(Sec("Can't start Winsock!"));
|
||||
@@ -249,5 +249,5 @@ void TCPServerMain(){
|
||||
}while(client);
|
||||
|
||||
closesocket(client);
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
@@ -124,13 +124,13 @@ void SyncClient(Client*c){
|
||||
}
|
||||
void ParseVeh(Client*c, const std::string& Packet){
|
||||
Assert(c);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
__try{
|
||||
VehicleParser(c,Packet);
|
||||
}__except(Handle(GetExceptionInformation(),Sec("Vehicle Handler"))){}
|
||||
#else // unix
|
||||
VehicleParser(c,Packet);
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
void HandleEvent(Client*c ,const std::string&Data){
|
||||
@@ -204,11 +204,11 @@ void GlobalParser(Client*c, const std::string& Pack){
|
||||
|
||||
void GParser(Client*c, const std::string& Packet){
|
||||
Assert(c);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
__try{
|
||||
GlobalParser(c, Packet);
|
||||
}__except(Handle(GetExceptionInformation(),Sec("Global Handler"))){}
|
||||
#else
|
||||
GlobalParser(c, Packet);
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@ void TCPSend(Client*c,const std::string&Data){
|
||||
}
|
||||
void TCPHandle(Client*c,const std::string& data){
|
||||
Assert(c);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
__try{
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
c->Handler.Handle(c,data);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
}__except(1){
|
||||
c->Handler.clear();
|
||||
}
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
void TCPRcv(Client*c){
|
||||
Assert(c);
|
||||
@@ -43,11 +43,11 @@ void TCPRcv(Client*c){
|
||||
if(c->GetStatus() > -1)c->SetStatus(-1);
|
||||
return;
|
||||
}else if (BytesRcv < 0) {
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
debug(Sec("(TCP) recv failed with error: ") + std::to_string(WSAGetLastError()));
|
||||
#else // unix
|
||||
debug(Sec("(TCP) recv failed with error: ") + std::string(strerror(errno)));
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
if(c->GetStatus() > -1)c->SetStatus(-1);
|
||||
closesocket(c->GetTCPSock());
|
||||
return;
|
||||
@@ -64,13 +64,13 @@ void TCPClient(Client*c){
|
||||
}
|
||||
OnConnect(c);
|
||||
while (c->GetStatus() > -1)TCPRcv(c);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
__try{
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
OnDisconnect(c, c->GetStatus() == -2);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
}__except(Handle(GetExceptionInformation(),Sec("OnDisconnect"))){}
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
void InitClient(Client*c){
|
||||
std::thread NewClient(TCPClient,c);
|
||||
|
||||
@@ -43,7 +43,7 @@ void UDPSend(Client* c, std::string Data) {
|
||||
Data = "ABG:" + CMP;
|
||||
}
|
||||
ssize_t sendOk = sendto(UDPSock, Data.c_str(), Data.size(), 0, (sockaddr*)&Addr, AddrSize);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
if (sendOk != 0) {
|
||||
debug(Sec("(UDP) Send Failed Code : ") + std::to_string(WSAGetLastError()));
|
||||
if (c->GetStatus() > -1)
|
||||
@@ -55,7 +55,7 @@ void UDPSend(Client* c, std::string Data) {
|
||||
if (c->GetStatus() > -1)
|
||||
c->SetStatus(-1);
|
||||
}
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
void AckID(int ID) {
|
||||
@@ -168,11 +168,11 @@ std::string UDPRcvFromClient(sockaddr_in& client) {
|
||||
std::string Ret(10240, 0);
|
||||
ssize_t Rcv = recvfrom(UDPSock, &Ret[0], 10240, 0, (sockaddr*)&client, (socklen_t*)&clientLength);
|
||||
if (Rcv == -1) {
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
error(Sec("(UDP) Error receiving from Client! Code : ") + std::to_string(WSAGetLastError()));
|
||||
#else // unix
|
||||
error(Sec("(UDP) Error receiving from Client! Code : ") + std::string(strerror(errno)));
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
return "";
|
||||
}
|
||||
return Ret;
|
||||
@@ -272,7 +272,7 @@ void LOOP() {
|
||||
}
|
||||
}
|
||||
[[noreturn]] void UDPServerMain() {
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
WSADATA data;
|
||||
if (WSAStartup(514, &data)) {
|
||||
error(Sec("Can't start Winsock!"));
|
||||
@@ -362,5 +362,5 @@ void LOOP() {
|
||||
/*closesocket(UDPSock); // TODO: Why not this? We did this in TCPServerMain?
|
||||
return;
|
||||
*/
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user