mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 14:26:09 +00:00
add lua engine, lua file, server, client, vehicle data, other stuff
This commit is contained in:
committed by
Anonymous275
parent
e5e447c7af
commit
459814a6ec
64
src/Client.cpp
Normal file
64
src/Client.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "Client.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// FIXME: add debug prints
|
||||
|
||||
void TClient::DeleteCar(int Ident) {
|
||||
for (auto& v : _VehicleData) {
|
||||
if (v != nullptr && v->ID() == Ident) {
|
||||
_VehicleData.erase(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TClient::ClearCars() {
|
||||
_VehicleData.clear();
|
||||
}
|
||||
|
||||
int TClient::GetOpenCarID() {
|
||||
int OpenID = 0;
|
||||
bool found;
|
||||
do {
|
||||
found = true;
|
||||
for (auto& v : _VehicleData) {
|
||||
if (v != nullptr && v->ID() == OpenID) {
|
||||
OpenID++;
|
||||
found = false;
|
||||
}
|
||||
}
|
||||
} while (!found);
|
||||
return OpenID;
|
||||
}
|
||||
|
||||
void TClient::AddNewCar(int Ident, const std::string& Data) {
|
||||
_VehicleData.insert(std::make_unique<TVehicleData>(TVehicleData { Ident, Data }));
|
||||
}
|
||||
|
||||
TClient::TSetOfVehicleData& TClient::GetAllCars() {
|
||||
return _VehicleData;
|
||||
}
|
||||
|
||||
std::string TClient::GetCarData(int Ident) {
|
||||
for (auto& v : _VehicleData) {
|
||||
if (v != nullptr && v->ID() == Ident) {
|
||||
return v->Data();
|
||||
}
|
||||
}
|
||||
DeleteCar(Ident);
|
||||
return "";
|
||||
}
|
||||
|
||||
void TClient::SetCarData(int Ident, const std::string& Data) {
|
||||
for (auto& v : _VehicleData) {
|
||||
if (v != nullptr && v->ID() == Ident) {
|
||||
v->Data() = Data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
DeleteCar(Ident);
|
||||
}
|
||||
int TClient::GetCarCount() {
|
||||
return int(_VehicleData.size());
|
||||
}
|
||||
Reference in New Issue
Block a user