Vehicle ghost fix, player list fix

This commit is contained in:
Anonymous275
2020-11-07 23:29:06 +02:00
parent 2021f0b461
commit a08d29a0ae
7 changed files with 84 additions and 125 deletions

View File

@@ -1,44 +0,0 @@
///
/// Created by Anonymous275 on 8/25/2020
///
#pragma once
#include <mutex>
#include "CustomAssert.h"
class Client;
void GParser(Client*c, const std::string&Packet);
class Buffer{
public:
void Handle(Client*c,const std::string& Data){
Assert(c);
Buf += Data;
Manage(c);
}
void clear(){
Buf.clear();
}
private:
std::string Buf;
void Manage(Client*c){
Assert(c);
if(!Buf.empty()){
std::string::size_type p;
if (Buf.at(0) == '\n'){
p = Buf.find('\n',1);
if(p != std::string::npos){
std::string R = Buf.substr(1,p-1);
std::string_view B(R.c_str(),R.find(char(0)));
GParser(c, B.data());
Buf = Buf.substr(p+1);
Manage(c);
}
}else{
p = Buf.find('\n');
if(p == std::string::npos)Buf.clear();
else{
Buf = Buf.substr(p);
Manage(c);
}
}
}
}
};

View File

@@ -9,7 +9,6 @@
#include <arpa/inet.h>
#define SOCKET int
#endif
#include "Buffer.h"
#include "CustomAssert.h"
#include <string>
#include <vector>
@@ -55,7 +54,6 @@ public:
int GetCarCount();
void ClearCars();
int GetStatus();
Buffer Handler;
int GetID();
};
struct ClientInterface{