mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
fixed vehicle spawn issue
This commit is contained in:
parent
ed0e35400d
commit
c5e1175f1a
@ -182,7 +182,6 @@ void HandleChunk(Client*c,const std::string&Data){
|
|||||||
void UDPParser(Client*c, const std::string&Packet){
|
void UDPParser(Client*c, const std::string&Packet){
|
||||||
if(Packet.substr(0,4) == "ACK:"){
|
if(Packet.substr(0,4) == "ACK:"){
|
||||||
AckID(stoi(Packet.substr(4)));
|
AckID(stoi(Packet.substr(4)));
|
||||||
std::cout << "Got Ack from " << c->GetName() << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}else if(Packet.substr(0,3) == "BD:"){
|
}else if(Packet.substr(0,3) == "BD:"){
|
||||||
int pos = Packet.find(':',4);
|
int pos = Packet.find(':',4);
|
||||||
|
@ -15,10 +15,11 @@ struct Sequence{
|
|||||||
bool Done = false;
|
bool Done = false;
|
||||||
};
|
};
|
||||||
void CreateNewThread(Client*client);
|
void CreateNewThread(Client*client);
|
||||||
void CreateClient(SOCKET TCPSock,const std::string &Name, const std::string &DID) {
|
void CreateClient(SOCKET TCPSock,const std::string &Name, const std::string &DID,const std::string &Role) {
|
||||||
auto *client = new Client;
|
auto *client = new Client;
|
||||||
client->SetTCPSock(TCPSock);
|
client->SetTCPSock(TCPSock);
|
||||||
client->SetName(Name);
|
client->SetName(Name);
|
||||||
|
client->SetRole(Role);
|
||||||
client->SetDID(DID);
|
client->SetDID(DID);
|
||||||
Clients.insert(client);
|
Clients.insert(client);
|
||||||
CreateNewThread(client);
|
CreateNewThread(client);
|
||||||
@ -57,12 +58,22 @@ void Check(Sequence* S){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Identification(SOCKET TCPSock){
|
void Identification(SOCKET TCPSock){
|
||||||
Sequence* S = new Sequence;
|
auto* S = new Sequence;
|
||||||
S->TCPSock = TCPSock;
|
S->TCPSock = TCPSock;
|
||||||
std::thread Timeout(Check,S);
|
std::thread Timeout(Check,S);
|
||||||
Timeout.detach();
|
Timeout.detach();
|
||||||
std::string Name,DID,Role,Res = TCPRcv(TCPSock);
|
std::string Name,DID,Role,Res = TCPRcv(TCPSock),Ver = TCPRcv(TCPSock);
|
||||||
S->Done = true;
|
S->Done = true;
|
||||||
|
if(Ver.size() > 3 && Ver.substr(0,2) == "VC"){
|
||||||
|
Ver = Ver.substr(2);
|
||||||
|
if(Ver.length() > 4 || Ver < ClientVersion){
|
||||||
|
closesocket(TCPSock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
closesocket(TCPSock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(Res.size() > 3 && Res.substr(0,2) == "NR"){
|
if(Res.size() > 3 && Res.substr(0,2) == "NR"){
|
||||||
if(Res.find(':') == std::string::npos){
|
if(Res.find(':') == std::string::npos){
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
@ -77,14 +88,14 @@ void Identification(SOCKET TCPSock){
|
|||||||
}
|
}
|
||||||
if(Debug)debug("Name -> " + Name + ", Role -> " + Role + ", ID -> " + DID);
|
if(Debug)debug("Name -> " + Name + ", Role -> " + Role + ", ID -> " + DID);
|
||||||
if(Role == "MDEV"){
|
if(Role == "MDEV"){
|
||||||
CreateClient(TCPSock,Name,DID);
|
CreateClient(TCPSock,Name,DID,Role);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Clients.size() < MaxPlayers)CreateClient(TCPSock,Name,DID);
|
if(Clients.size() < MaxPlayers)CreateClient(TCPSock,Name,DID,Role);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPServerMain(){
|
void TCPServerMain(){
|
||||||
|
@ -18,7 +18,7 @@ void addToLog(const std::string& Data);
|
|||||||
//void ServerMain(int Port, int MaxClients);
|
//void ServerMain(int Port, int MaxClients);
|
||||||
void HeartbeatInit();
|
void HeartbeatInit();
|
||||||
std::string ServerVersion = "0.4";
|
std::string ServerVersion = "0.4";
|
||||||
std::string ClientVersion = "1.4+";
|
std::string ClientVersion = "1.4";
|
||||||
std::string CustomIP;
|
std::string CustomIP;
|
||||||
void HandleResources(std::string path);
|
void HandleResources(std::string path);
|
||||||
void StatInit();
|
void StatInit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user