Vehicle ghost fix, server list fix

This commit is contained in:
Anonymous275
2020-11-07 23:29:42 +02:00
parent 7c2871f1b3
commit a2b6b29ea1
8 changed files with 60 additions and 98 deletions

View File

@@ -1,40 +0,0 @@
///
/// Created by Anonymous275 on 8/25/2020
///
#pragma once
void ServerParser(const std::string& Data);
class Buffer{
public:
void Handle(const std::string& Data){
Buf += Data;
Manage();
}
void clear(){
Buf.clear();
}
private:
std::string Buf;
void Manage(){
if(!Buf.empty()){
std::string::size_type p;
if (Buf.at(0) == '\n'){
p = Buf.find('\n',1);
if(p != -1){
std::string R = Buf.substr(1,p-1);
std::string_view B(R.c_str(),R.find(char(0)));
ServerParser(B.data());
Buf = Buf.substr(p+1);
Manage();
}
}else{
p = Buf.find('\n');
if(p == -1)Buf.clear();
else{
Buf = Buf.substr(p);
Manage();
}
}
}
}
};

View File

@@ -3,13 +3,11 @@
///
#pragma once
#include <string>
#include "Buffer.h"
void NetReset();
extern long long ping;
extern bool Dev;
void ClearAll();
extern int ClientID;
extern Buffer Handler;
extern bool ModLoaded;
extern bool Terminate;
extern int DEFAULT_PORT;