Final Commit v1.20

This commit is contained in:
Anonymous275 2020-12-22 00:25:55 +02:00
parent f94252d37b
commit ef8f8645f7
5 changed files with 41 additions and 30 deletions

View File

@ -135,18 +135,20 @@ void Default() {
_Exit(0); _Exit(0);
} }
void DebugData() { void DebugData() {
debug(std::string(("Debug : ")) + (Debug ? "true" : "false")); debug(std::string("Debug : ") + (Debug ? "true" : "false"));
debug(std::string(("Private : ")) + (Private ? "true" : "false")); debug(std::string("Private : ") + (Private ? "true" : "false"));
debug(("Port : ") + std::to_string(Port)); debug("Port : " + std::to_string(Port));
debug(("Max Cars : ") + std::to_string(MaxCars)); debug("Max Cars : " + std::to_string(MaxCars));
debug(("MaxPlayers : ") + std::to_string(MaxPlayers)); debug("MaxPlayers : " + std::to_string(MaxPlayers));
debug(("MapName : ") + MapName); debug("MapName : " + MapName);
debug(("ServerName : ") + ServerName); debug("ServerName : " + ServerName);
debug(("ServerDesc : ") + ServerDesc); debug("ServerDesc : " + ServerDesc);
debug(("File : ") + Resource); debug("File : " + Resource);
debug(("Key length: ") + std::to_string(Key.length())); debug("Key length: " + std::to_string(Key.length()));
} }
void InitConfig() { void InitConfig() {
////TODO: Move to json after update 4
std::ifstream IFS; std::ifstream IFS;
IFS.open(("Server.cfg")); IFS.open(("Server.cfg"));
if (IFS.good()) if (IFS.good())

View File

@ -16,7 +16,7 @@ std::string GetSVer() {
return "1.20"; return "1.20";
} }
std::string GetCVer() { std::string GetCVer() {
return "1.72"; return "1.80";
} }
void Args(int argc, char* argv[]) { void Args(int argc, char* argv[]) {
info("BeamMP Server Running version " + GetSVer()); info("BeamMP Server Running version " + GetSVer());

View File

@ -69,7 +69,7 @@ void Authentication(SOCKET TCPSock) {
json::Document d; json::Document d;
d.Parse(Rc.c_str()); d.Parse(Rc.c_str());
if(Rc == "-1" || d.HasParseError()){ if(Rc == "-1" || d.HasParseError()){
ClientKick(c,"Invalid key!"); ClientKick(c,"Invalid key! Please restart your game.");
return; return;
} }

View File

@ -14,25 +14,36 @@
#include "UnixCompat.h" #include "UnixCompat.h"
#include <memory> #include <memory>
#include <sstream> #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) { void Apply(Client* c, int VID, const std::string& pckt) {
Assert(c); Assert(c);
std::string Packet = pckt; std::string Packet = pckt.substr(pckt.find('{')), VD = c->GetCarData(VID);
std::string VD = c->GetCarData(VID); std::string Header = VD.substr(0,VD.find('{'));
Packet = Packet.substr(FC(Packet, ",", 2) + 1); VD = VD.substr(VD.find('{'));
Packet = VD.substr(0, FC(VD, ",", 2) + 1) + Packet.substr(0, Packet.find_last_of('"') + 1) + VD.substr(FC(VD, ",\"", 7)); rapidjson::Document Veh, Pack;
c->SetCarData(VID, Packet); 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) { void VehicleParser(Client* c, const std::string& Pckt) {

View File

@ -19,8 +19,6 @@
#include <vector> #include <vector>
#include <cmath> #include <cmath>
int FC(const std::string& s, const std::string& p, int n);
SOCKET UDPSock; SOCKET UDPSock;
void UDPSend(Client* c, std::string Data) { void UDPSend(Client* c, std::string Data) {
Assert(c); Assert(c);