mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 08:15:35 +00:00
change __WIN32 to WIN32 (oops)
This commit is contained in:
parent
e9432ac1ca
commit
e986df0579
@ -9,6 +9,9 @@ if (UNIX)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s")
|
||||
elseif (WIN32)
|
||||
# This might cause issues with old windows headers, but it's worth the trouble to keep the code
|
||||
# completely cross platform. For fixes to common issues arising from /permissive- visit:
|
||||
# https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /permissive-")
|
||||
endif ()
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
///
|
||||
|
||||
#pragma once
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
#include <WS2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
|
@ -38,7 +38,7 @@
|
||||
* Define WIN32 when build target is Win32 API
|
||||
*/
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && \
|
||||
#if (defined(_WIN32) || defined(WIN32__)) && \
|
||||
!defined(WIN32) && !defined(__SYMBIAN32__)
|
||||
#define WIN32
|
||||
#endif
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// This header defines unix equivalents of common win32 functions.
|
||||
|
||||
#ifndef __WIN32
|
||||
#ifndef WIN32
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
@ -27,4 +27,4 @@ inline void closesocket(int socket) {
|
||||
#define __except(x) /**/
|
||||
#endif
|
||||
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
|
@ -176,7 +176,7 @@
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
|
@ -133,7 +133,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
# define OS_CODE 7
|
||||
# ifndef Z_SOLO
|
||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != WIN32_os
|
||||
# include <unix.h> /* for fdopen */
|
||||
# else
|
||||
# ifndef fdopen
|
||||
|
@ -3,14 +3,14 @@
|
||||
///
|
||||
|
||||
#include "Lua/LuaSystem.hpp"
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <conio.h>
|
||||
#else // *nix
|
||||
typedef unsigned long DWORD, *PDWORD, *LPDWORD;
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
#include "Logger.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -54,7 +54,7 @@ void ConsoleOut(const std::string& msg){
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __WIN32
|
||||
#ifndef WIN32
|
||||
static int _getch()
|
||||
{
|
||||
char buf = 0;
|
||||
@ -77,10 +77,10 @@ static int _getch()
|
||||
// no echo printf("%c\n", buf);
|
||||
return buf;
|
||||
}
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
|
||||
void SetupConsole(){
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
DWORD outMode = 0;
|
||||
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (stdoutHandle == INVALID_HANDLE_VALUE){
|
||||
@ -101,7 +101,7 @@ void SetupConsole(){
|
||||
exit(GetLastError());
|
||||
}
|
||||
#else
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
[[noreturn]] void ReadCin(){
|
||||
|
@ -85,7 +85,7 @@ int Dec(int value,int d,int n){
|
||||
return log_power(value, d, n);
|
||||
}
|
||||
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
int Handle(EXCEPTION_POINTERS *ep,char* Origin){
|
||||
assert(false);
|
||||
std::stringstream R;
|
||||
@ -98,7 +98,7 @@ int Handle(EXCEPTION_POINTERS *ep,char* Origin){
|
||||
#else
|
||||
// stub
|
||||
int Handle(EXCEPTION_POINTERS *, char*) { return 1; }
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
|
||||
std::string RSA_E(const std::string& Data, RSA*k){
|
||||
std::stringstream stream;
|
||||
|
@ -143,7 +143,7 @@ void SafeExecution(Lua* lua,const std::string& FuncName){
|
||||
lua_getglobal(luaState, FuncName.c_str());
|
||||
if(lua_isfunction(luaState, -1)) {
|
||||
char* Origin = ThreadOrigin(lua);
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
__try{
|
||||
int R = lua_pcall(luaState, 0, 0, 0);
|
||||
CheckLua(luaState, R);
|
||||
@ -151,7 +151,7 @@ void SafeExecution(Lua* lua,const std::string& FuncName){
|
||||
#else // unix
|
||||
int R = lua_pcall(luaState, 0, 0, 0);
|
||||
CheckLua(luaState, R);
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
delete [] Origin;
|
||||
}
|
||||
ClearStack(luaState);
|
||||
@ -515,18 +515,18 @@ int CallFunction(Lua*lua,const std::string& FuncName,LuaArg* Arg){
|
||||
}
|
||||
int R = 0;
|
||||
char* Origin = lua->GetOrigin();
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
__try{
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
R = lua_pcall(luaState, Size, 1, 0);
|
||||
if (CheckLua(luaState, R)){
|
||||
if (lua_isnumber(luaState, -1)) {
|
||||
return int(lua_tointeger(luaState, -1));
|
||||
}
|
||||
}
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
}__except(Handle(GetExceptionInformation(),Origin)){}
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
delete [] Origin;
|
||||
}
|
||||
ClearStack(luaState);
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ std::string getDate() {
|
||||
auto s = std::chrono::duration_cast<std::chrono::seconds>(tp);tp -= s;
|
||||
time_t tt = std::chrono::system_clock::to_time_t(now);
|
||||
tm local_tm{};
|
||||
#ifdef __WIN32
|
||||
#ifdef WIN32
|
||||
localtime_s(&local_tm,&tt);
|
||||
#else // unix
|
||||
localtime_r(&tt, &local_tm);
|
||||
#endif // __WIN32
|
||||
#endif // WIN32
|
||||
std::stringstream date;
|
||||
int S = local_tm.tm_sec;
|
||||
int M = local_tm.tm_min;
|
||||
|
Loading…
x
Reference in New Issue
Block a user