statistics

This commit is contained in:
Anonymous275 2020-06-20 14:55:27 +03:00
parent 280e3a8daa
commit 62928ece9c
5 changed files with 21 additions and 9 deletions

View File

@ -21,6 +21,7 @@ int PPS = 0;
}else{
R = PPS/C;
StatReport = std::to_string(R);
PPS = 0;
}
}
std::this_thread::sleep_for(std::chrono::seconds(1));

View File

@ -9,7 +9,8 @@ namespace fs = std::filesystem;
std::string FileList;
std::string FileSizes;
int ModsLoaded = 0;
int MaxModSize = 0;
void LuaMain(std::string Path);
void HandleResources(std::string path){
struct stat info{};
@ -27,6 +28,8 @@ void HandleResources(std::string path){
if(entry.path().string().length() - pos == 4){
FileList += entry.path().string() + ";";
FileSizes += std::to_string(fs::file_size(entry.path()))+";";
MaxModSize += fs::file_size(entry.path());
ModsLoaded++;
}
}
}

View File

@ -12,6 +12,8 @@ extern std::string CustomIP;
extern std::string MapName;
extern std::string Key;
extern int MaxPlayers;
extern int ModsLoaded;
extern int MaxModSize;
extern bool Private;
extern int MaxCars;
extern bool Debug;

View File

@ -24,29 +24,32 @@ std::string HTA(const std::string& hex)
}
void Heartbeat()
{
//string UUID = HTTP_REQUEST("https://beamng-mp.com/new-server-startup",443);
std::string State,R;
std::string State,R,T;
while(true)
{
State = Private ? "true" : "false";
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+
"&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;
// https://beamng-mp.com/heartbeatv2
R = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
if(R.find_first_not_of("20") != std::string::npos){
T = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
if(T.find_first_not_of("20") != std::string::npos){
//Backend system refused server startup!
std::this_thread::sleep_for(std::chrono::seconds(10));
R = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
if(R.find_first_not_of("20") != std::string::npos){
T = PostHTTP(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6865617274626561747632"),R);
if(T.find_first_not_of("20") != std::string::npos){
error(HTA("4261636b656e642073797374656d20726566757365642073657276657221"));
std::this_thread::sleep_for(std::chrono::seconds(3));
exit(-1);
}
}
//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));
}
}

View File

@ -44,6 +44,9 @@ int main(int argc, char* argv[]) {
/*std::thread TCPThread(TCPMain,Port);
TCPThread.detach();*/
//ServerMain(Port, MaxPlayers);
if(ModsLoaded){
info("Loaded "+std::to_string(ModsLoaded)+" Mods");
}
StatInit();
NetMain();
}