mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-02 15:55:30 +00:00
Final Commit v1.20
This commit is contained in:
parent
f94252d37b
commit
ef8f8645f7
@ -135,18 +135,20 @@ void Default() {
|
||||
_Exit(0);
|
||||
}
|
||||
void DebugData() {
|
||||
debug(std::string(("Debug : ")) + (Debug ? "true" : "false"));
|
||||
debug(std::string(("Private : ")) + (Private ? "true" : "false"));
|
||||
debug(("Port : ") + std::to_string(Port));
|
||||
debug(("Max Cars : ") + std::to_string(MaxCars));
|
||||
debug(("MaxPlayers : ") + std::to_string(MaxPlayers));
|
||||
debug(("MapName : ") + MapName);
|
||||
debug(("ServerName : ") + ServerName);
|
||||
debug(("ServerDesc : ") + ServerDesc);
|
||||
debug(("File : ") + Resource);
|
||||
debug(("Key length: ") + std::to_string(Key.length()));
|
||||
debug(std::string("Debug : ") + (Debug ? "true" : "false"));
|
||||
debug(std::string("Private : ") + (Private ? "true" : "false"));
|
||||
debug("Port : " + std::to_string(Port));
|
||||
debug("Max Cars : " + std::to_string(MaxCars));
|
||||
debug("MaxPlayers : " + std::to_string(MaxPlayers));
|
||||
debug("MapName : " + MapName);
|
||||
debug("ServerName : " + ServerName);
|
||||
debug("ServerDesc : " + ServerDesc);
|
||||
debug("File : " + Resource);
|
||||
debug("Key length: " + std::to_string(Key.length()));
|
||||
}
|
||||
void InitConfig() {
|
||||
////TODO: Move to json after update 4
|
||||
|
||||
std::ifstream IFS;
|
||||
IFS.open(("Server.cfg"));
|
||||
if (IFS.good())
|
||||
|
@ -16,7 +16,7 @@ std::string GetSVer() {
|
||||
return "1.20";
|
||||
}
|
||||
std::string GetCVer() {
|
||||
return "1.72";
|
||||
return "1.80";
|
||||
}
|
||||
void Args(int argc, char* argv[]) {
|
||||
info("BeamMP Server Running version " + GetSVer());
|
||||
|
@ -69,7 +69,7 @@ void Authentication(SOCKET TCPSock) {
|
||||
json::Document d;
|
||||
d.Parse(Rc.c_str());
|
||||
if(Rc == "-1" || d.HasParseError()){
|
||||
ClientKick(c,"Invalid key!");
|
||||
ClientKick(c,"Invalid key! Please restart your game.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -14,25 +14,36 @@
|
||||
#include "UnixCompat.h"
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include "Json.h"
|
||||
|
||||
int FC(const std::string& s, const std::string& p, int n) {
|
||||
auto i = s.find(p);
|
||||
int j;
|
||||
for (j = 1; j < n && i != std::string::npos; ++j) {
|
||||
i = s.find(p, i + 1);
|
||||
}
|
||||
if (j == n)
|
||||
return int(i);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
void Apply(Client* c, int VID, const std::string& pckt) {
|
||||
Assert(c);
|
||||
std::string Packet = pckt;
|
||||
std::string VD = c->GetCarData(VID);
|
||||
Packet = Packet.substr(FC(Packet, ",", 2) + 1);
|
||||
Packet = VD.substr(0, FC(VD, ",", 2) + 1) + Packet.substr(0, Packet.find_last_of('"') + 1) + VD.substr(FC(VD, ",\"", 7));
|
||||
c->SetCarData(VID, Packet);
|
||||
std::string Packet = pckt.substr(pckt.find('{')), VD = c->GetCarData(VID);
|
||||
std::string Header = VD.substr(0,VD.find('{'));
|
||||
VD = VD.substr(VD.find('{'));
|
||||
rapidjson::Document Veh, Pack;
|
||||
Veh.Parse(VD.c_str());
|
||||
if(Veh.HasParseError()){
|
||||
error("Could not get vehicle config!");
|
||||
return;
|
||||
}
|
||||
Pack.Parse(Packet.c_str());
|
||||
if(Pack.HasParseError() || Pack.IsNull()){
|
||||
error("Could not get active vehicle config!");
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto& M : Pack.GetObjectA()){
|
||||
if(Veh[M.name].IsNull()){
|
||||
Veh.AddMember(M.name,M.value,Veh.GetAllocator());
|
||||
}else{
|
||||
Veh[M.name] = Pack[M.name];
|
||||
}
|
||||
}
|
||||
rapidjson::StringBuffer Buffer;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(Buffer);
|
||||
Veh.Accept(writer);
|
||||
c->SetCarData(VID, Header + Buffer.GetString());
|
||||
}
|
||||
|
||||
void VehicleParser(Client* c, const std::string& Pckt) {
|
||||
|
@ -19,8 +19,6 @@
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
int FC(const std::string& s, const std::string& p, int n);
|
||||
|
||||
SOCKET UDPSock;
|
||||
void UDPSend(Client* c, std::string Data) {
|
||||
Assert(c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user