mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 16:25:35 +00:00
statistics
This commit is contained in:
parent
280e3a8daa
commit
62928ece9c
@ -21,6 +21,7 @@ int PPS = 0;
|
|||||||
}else{
|
}else{
|
||||||
R = PPS/C;
|
R = PPS/C;
|
||||||
StatReport = std::to_string(R);
|
StatReport = std::to_string(R);
|
||||||
|
PPS = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
@ -9,7 +9,8 @@ namespace fs = std::filesystem;
|
|||||||
|
|
||||||
std::string FileList;
|
std::string FileList;
|
||||||
std::string FileSizes;
|
std::string FileSizes;
|
||||||
|
int ModsLoaded = 0;
|
||||||
|
int MaxModSize = 0;
|
||||||
void LuaMain(std::string Path);
|
void LuaMain(std::string Path);
|
||||||
void HandleResources(std::string path){
|
void HandleResources(std::string path){
|
||||||
struct stat info{};
|
struct stat info{};
|
||||||
@ -27,6 +28,8 @@ void HandleResources(std::string path){
|
|||||||
if(entry.path().string().length() - pos == 4){
|
if(entry.path().string().length() - pos == 4){
|
||||||
FileList += entry.path().string() + ";";
|
FileList += entry.path().string() + ";";
|
||||||
FileSizes += std::to_string(fs::file_size(entry.path()))+";";
|
FileSizes += std::to_string(fs::file_size(entry.path()))+";";
|
||||||
|
MaxModSize += fs::file_size(entry.path());
|
||||||
|
ModsLoaded++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ extern std::string CustomIP;
|
|||||||
extern std::string MapName;
|
extern std::string MapName;
|
||||||
extern std::string Key;
|
extern std::string Key;
|
||||||
extern int MaxPlayers;
|
extern int MaxPlayers;
|
||||||
|
extern int ModsLoaded;
|
||||||
|
extern int MaxModSize;
|
||||||
extern bool Private;
|
extern bool Private;
|
||||||
extern int MaxCars;
|
extern int MaxCars;
|
||||||
extern bool Debug;
|
extern bool Debug;
|
||||||
|
@ -24,29 +24,32 @@ std::string HTA(const std::string& hex)
|
|||||||
}
|
}
|
||||||
void Heartbeat()
|
void Heartbeat()
|
||||||
{
|
{
|
||||||
//string UUID = HTTP_REQUEST("https://beamng-mp.com/new-server-startup",443);
|
std::string State,R,T;
|
||||||
std::string State,R;
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
State = Private ? "true" : "false";
|
State = Private ? "true" : "false";
|
||||||
R = "uuid="+Key+"&players="+std::to_string(Clients.size())+"&maxplayers="+std::to_string(MaxPlayers)+"&port="
|
R = "uuid="+Key+"&players="+std::to_string(Clients.size())+"&maxplayers="+std::to_string(MaxPlayers)+"&port="
|
||||||
+ std::to_string(Port) + "&map=" + MapName + "&private="+State+"&version="+ServerVersion+
|
+ std::to_string(Port) + "&map=" + MapName + "&private="+State+"&version="+ServerVersion+
|
||||||
"&clientversion="+ClientVersion+"&name="+ServerName+"&pps="+StatReport;
|
"&clientversion="+ClientVersion+"&name="+ServerName+"&pps="+StatReport+"&modlist="+FileList+
|
||||||
|
"&modstotalsize="+std::to_string(MaxModSize)+"&modstotal="+std::to_string(ModsLoaded);
|
||||||
if(!CustomIP.empty())R+="&ip="+CustomIP;
|
if(!CustomIP.empty())R+="&ip="+CustomIP;
|
||||||
// https://beamng-mp.com/heartbeatv2
|
// https://beamng-mp.com/heartbeatv2
|
||||||
R = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
|
T = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
|
||||||
if(R.find_first_not_of("20") != std::string::npos){
|
if(T.find_first_not_of("20") != std::string::npos){
|
||||||
//Backend system refused server startup!
|
//Backend system refused server startup!
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
R = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
|
T = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
|
||||||
if(R.find_first_not_of("20") != std::string::npos){
|
if(T.find_first_not_of("20") != std::string::npos){
|
||||||
error(HTA("4261636b656e642073797374656d20726566757365642073657276657221"));
|
error(HTA("4261636b656e642073797374656d20726566757365642073657276657221"));
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Server Authenticated
|
//Server Authenticated
|
||||||
if(R.length() == 4)info(HTA("5365727665722061757468656e746963617465642077697468206261636b656e64"));
|
if(T.length() == 4)info(HTA("5365727665722061757468656e746963617465642077697468206261636b656e64"));
|
||||||
|
R.clear();
|
||||||
|
T.clear();
|
||||||
|
State.clear();
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,9 @@ int main(int argc, char* argv[]) {
|
|||||||
/*std::thread TCPThread(TCPMain,Port);
|
/*std::thread TCPThread(TCPMain,Port);
|
||||||
TCPThread.detach();*/
|
TCPThread.detach();*/
|
||||||
//ServerMain(Port, MaxPlayers);
|
//ServerMain(Port, MaxPlayers);
|
||||||
|
if(ModsLoaded){
|
||||||
|
info("Loaded "+std::to_string(ModsLoaded)+" Mods");
|
||||||
|
}
|
||||||
StatInit();
|
StatInit();
|
||||||
NetMain();
|
NetMain();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user