mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 14:26:09 +00:00
add udpserver, tcpserver
This commit is contained in:
committed by
Anonymous275
parent
f19a012509
commit
bf74b1ae32
@@ -1,28 +1,29 @@
|
||||
#include "Client.h"
|
||||
|
||||
#include "CustomAssert.h"
|
||||
#include <memory>
|
||||
|
||||
// FIXME: add debug prints
|
||||
|
||||
void TClient::DeleteCar(int Ident) {
|
||||
for (auto& v : _VehicleData) {
|
||||
for (auto& v : mVehicleData) {
|
||||
if (v != nullptr && v->ID() == Ident) {
|
||||
_VehicleData.erase(v);
|
||||
mVehicleData.erase(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TClient::ClearCars() {
|
||||
_VehicleData.clear();
|
||||
mVehicleData.clear();
|
||||
}
|
||||
|
||||
int TClient::GetOpenCarID() {
|
||||
int TClient::GetOpenCarID() const {
|
||||
int OpenID = 0;
|
||||
bool found;
|
||||
do {
|
||||
found = true;
|
||||
for (auto& v : _VehicleData) {
|
||||
for (auto& v : mVehicleData) {
|
||||
if (v != nullptr && v->ID() == OpenID) {
|
||||
OpenID++;
|
||||
found = false;
|
||||
@@ -33,15 +34,15 @@ int TClient::GetOpenCarID() {
|
||||
}
|
||||
|
||||
void TClient::AddNewCar(int Ident, const std::string& Data) {
|
||||
_VehicleData.insert(std::make_unique<TVehicleData>(TVehicleData { Ident, Data }));
|
||||
mVehicleData.insert(std::make_unique<TVehicleData>(TVehicleData { Ident, Data }));
|
||||
}
|
||||
|
||||
TClient::TSetOfVehicleData& TClient::GetAllCars() {
|
||||
return _VehicleData;
|
||||
return mVehicleData;
|
||||
}
|
||||
|
||||
std::string TClient::GetCarData(int Ident) {
|
||||
for (auto& v : _VehicleData) {
|
||||
for (auto& v : mVehicleData) {
|
||||
if (v != nullptr && v->ID() == Ident) {
|
||||
return v->Data();
|
||||
}
|
||||
@@ -51,7 +52,7 @@ std::string TClient::GetCarData(int Ident) {
|
||||
}
|
||||
|
||||
void TClient::SetCarData(int Ident, const std::string& Data) {
|
||||
for (auto& v : _VehicleData) {
|
||||
for (auto& v : mVehicleData) {
|
||||
if (v != nullptr && v->ID() == Ident) {
|
||||
v->Data() = Data;
|
||||
return;
|
||||
@@ -59,6 +60,13 @@ void TClient::SetCarData(int Ident, const std::string& Data) {
|
||||
}
|
||||
DeleteCar(Ident);
|
||||
}
|
||||
int TClient::GetCarCount() {
|
||||
return int(_VehicleData.size());
|
||||
int TClient::GetCarCount() const {
|
||||
return int(mVehicleData.size());
|
||||
}
|
||||
TServer& TClient::Server() const {
|
||||
return mServer;
|
||||
}
|
||||
|
||||
TClient::TClient(TServer& Server)
|
||||
: mServer(Server) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user