mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-05-19 16:10:14 +00:00
small fixes
This commit is contained in:
+2
-2
@@ -38,11 +38,11 @@ std::string Decompress(const std::string&Data)
|
|||||||
{
|
{
|
||||||
std::string c;
|
std::string c;
|
||||||
c.resize(Data.size()*5);
|
c.resize(Data.size()*5);
|
||||||
z_stream infstream,defstream;
|
z_stream infstream;
|
||||||
infstream.zalloc = Z_NULL;
|
infstream.zalloc = Z_NULL;
|
||||||
infstream.zfree = Z_NULL;
|
infstream.zfree = Z_NULL;
|
||||||
infstream.opaque = Z_NULL;
|
infstream.opaque = Z_NULL;
|
||||||
infstream.avail_in = (uInt)((char*)defstream.next_out - Data.c_str());
|
infstream.avail_in = (uInt)(Data.c_str());
|
||||||
infstream.next_in = (Bytef *)&Data[0];
|
infstream.next_in = (Bytef *)&Data[0];
|
||||||
infstream.avail_out = (uInt)c.size();
|
infstream.avail_out = (uInt)c.size();
|
||||||
infstream.next_out = (Bytef *)&c[0];
|
infstream.next_out = (Bytef *)&c[0];
|
||||||
|
|||||||
@@ -1522,7 +1522,7 @@ static int enet_protocol_dispatch_incoming_commands(ENetHost *host, ENetEvent *e
|
|||||||
}
|
}
|
||||||
|
|
||||||
event->packet = enet_peer_receive(peer, &event->channelID);
|
event->packet = enet_peer_receive(peer, &event->channelID);
|
||||||
if (event->packet == NULL) {
|
if (event->packet == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3583,20 +3583,16 @@ ENetPacket * enet_peer_receive(ENetPeer *peer, enet_uint8 *channelID) {
|
|||||||
ENetIncomingCommand *incomingCommand;
|
ENetIncomingCommand *incomingCommand;
|
||||||
ENetPacket *packet;
|
ENetPacket *packet;
|
||||||
|
|
||||||
if (enet_list_empty(&peer->dispatchedCommands)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
incomingCommand = (ENetIncomingCommand *)enet_list_remove(enet_list_begin(&peer->dispatchedCommands));
|
incomingCommand = (ENetIncomingCommand *)enet_list_remove(enet_list_begin(&peer->dispatchedCommands));
|
||||||
|
|
||||||
if (channelID != NULL) {
|
if (channelID != nullptr) {
|
||||||
*channelID = incomingCommand->command.header.channelID;
|
*channelID = incomingCommand->command.header.channelID;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet = incomingCommand->packet;
|
packet = incomingCommand->packet;
|
||||||
--packet->referenceCount;
|
--packet->referenceCount;
|
||||||
|
|
||||||
if (incomingCommand->fragments != NULL) {
|
if (incomingCommand->fragments != nullptr) {
|
||||||
enet_free(incomingCommand->fragments);
|
enet_free(incomingCommand->fragments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3612,7 +3608,7 @@ static void enet_peer_reset_outgoing_commands(ENetList *queue) {
|
|||||||
while (!enet_list_empty(queue)) {
|
while (!enet_list_empty(queue)) {
|
||||||
outgoingCommand = (ENetOutgoingCommand *) enet_list_remove(enet_list_begin(queue));
|
outgoingCommand = (ENetOutgoingCommand *) enet_list_remove(enet_list_begin(queue));
|
||||||
|
|
||||||
if (outgoingCommand->packet != NULL) {
|
if (outgoingCommand->packet != nullptr) {
|
||||||
--outgoingCommand->packet->referenceCount;
|
--outgoingCommand->packet->referenceCount;
|
||||||
|
|
||||||
if (outgoingCommand->packet->referenceCount == 0) {
|
if (outgoingCommand->packet->referenceCount == 0) {
|
||||||
@@ -103,7 +103,7 @@ int main(int argc, char* argv[]){
|
|||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Client Connected!" << std::endl;
|
||||||
HTTP_Result = HTTP_REQUEST("https://beamng-mp.com/entitlement?did="+GlobalInfo.at(2),443);
|
HTTP_Result = HTTP_REQUEST("https://beamng-mp.com/entitlement?did="+GlobalInfo.at(2),443);
|
||||||
if(HTTP_Result.find("\"MDEV\"") == NPos){
|
if(HTTP_Result.find("\"MDEV\"") == NPos){
|
||||||
if (HTTP_Result.find("\"MOD\"") == NPos && HTTP_Result.find("\"EA\"") == NPos){
|
if (HTTP_Result.find("\"MOD\"") == NPos && HTTP_Result.find("\"EA\"") == NPos){
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#define ENET_IMPLEMENTATION
|
#define ENET_IMPLEMENTATION
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include "include/enet.h"
|
#include "include/enet.hpp"
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -23,7 +23,7 @@ std::chrono::time_point<std::chrono::steady_clock> PingStart,PingEnd;
|
|||||||
extern std::vector<std::string> GlobalInfo;
|
extern std::vector<std::string> GlobalInfo;
|
||||||
std::condition_variable RUDPLOCK,TCPLOCK;
|
std::condition_variable RUDPLOCK,TCPLOCK;
|
||||||
std::queue<std::string> RUDPToSend;
|
std::queue<std::string> RUDPToSend;
|
||||||
std::queue<std::string> RUDPData;
|
std::queue<std::string> RUDPData; /////QUEUE WAS 196 SLOW?! NEED TO FIX
|
||||||
bool TCPTerminate = false;
|
bool TCPTerminate = false;
|
||||||
bool Terminate = false;
|
bool Terminate = false;
|
||||||
bool CServer = true;
|
bool CServer = true;
|
||||||
@@ -100,7 +100,6 @@ void RUDPClientThread(const std::string& IP, int Port){
|
|||||||
if (enet_initialize() != 0) {
|
if (enet_initialize() != 0) {
|
||||||
std::cout << "An error occurred while initializing!\n";
|
std::cout << "An error occurred while initializing!\n";
|
||||||
}
|
}
|
||||||
std::mutex Lock;
|
|
||||||
Client client;
|
Client client;
|
||||||
ENetAddress address = {0};
|
ENetAddress address = {0};
|
||||||
|
|
||||||
@@ -137,6 +136,7 @@ void RUDPClientThread(const std::string& IP, int Port){
|
|||||||
}
|
}
|
||||||
RUDPToSend.pop();
|
RUDPToSend.pop();
|
||||||
}
|
}
|
||||||
|
std::mutex Lock;
|
||||||
std::unique_lock<std::mutex> lk(Lock);
|
std::unique_lock<std::mutex> lk(Lock);
|
||||||
std::chrono::high_resolution_clock::time_point tp = std::chrono::high_resolution_clock::now() + std::chrono::nanoseconds (1);
|
std::chrono::high_resolution_clock::time_point tp = std::chrono::high_resolution_clock::now() + std::chrono::nanoseconds (1);
|
||||||
RUDPLOCK.wait_until(lk, tp, [](){return !RUDPToSend.empty();});
|
RUDPLOCK.wait_until(lk, tp, [](){return !RUDPToSend.empty();});
|
||||||
@@ -152,7 +152,6 @@ void RUDPClientThread(const std::string& IP, int Port){
|
|||||||
void TCPRespond(const SOCKET *CS){
|
void TCPRespond(const SOCKET *CS){
|
||||||
SOCKET ClientSocket = *CS;
|
SOCKET ClientSocket = *CS;
|
||||||
int iSendResult;
|
int iSendResult;
|
||||||
std::mutex Lock;
|
|
||||||
while(!TCPTerminate){
|
while(!TCPTerminate){
|
||||||
while (!RUDPData.empty()) {
|
while (!RUDPData.empty()) {
|
||||||
std::string Data = RUDPData.front() + "\n";
|
std::string Data = RUDPData.front() + "\n";
|
||||||
@@ -170,6 +169,7 @@ void TCPRespond(const SOCKET *CS){
|
|||||||
RUDPData.pop();
|
RUDPData.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::mutex Lock;
|
||||||
std::unique_lock<std::mutex> lk(Lock);
|
std::unique_lock<std::mutex> lk(Lock);
|
||||||
std::chrono::high_resolution_clock::time_point tp = std::chrono::high_resolution_clock::now() + std::chrono::milliseconds(1);
|
std::chrono::high_resolution_clock::time_point tp = std::chrono::high_resolution_clock::now() + std::chrono::milliseconds(1);
|
||||||
TCPLOCK.wait_until(lk, tp, [](){return !RUDPData.empty();});
|
TCPLOCK.wait_until(lk, tp, [](){return !RUDPData.empty();});
|
||||||
|
|||||||
Reference in New Issue
Block a user