i broke it some what sorry Anon

This commit is contained in:
Starystars67 2020-04-10 19:14:06 +01:00
parent 388cffbe01
commit 9bdec9e5f8
4 changed files with 41 additions and 28 deletions

View File

@ -6,5 +6,5 @@ include_directories(${PROJECT_SOURCE_DIR}/curl)
set(CMAKE_CXX_STANDARD 14)
add_executable(BeamMP-Server src/main.cpp src/http.cpp src/logger.cpp src/config.cpp src/Network/Server.cpp src/Network/enet.h src/Network/DataParser.cpp src/heartbeat.cpp src/Network/ClientHandler.cpp src/Network/functions.cpp)
add_executable(BeamMP-Server src/main.cpp src/http.cpp src/logger.cpp src/config.cpp src/Network/Server.cpp src/Network/enet.h src/Network/DataParser.cpp src/heartbeat.cpp src/Network/ClientHandler.cpp src/Network/functions.cpp src/settings.h)
target_link_libraries(BeamMP-Server winmm ws2_32 libcurl_a)

View File

@ -6,20 +6,14 @@
#include <iostream>
#include <string>
#include <chrono>
#include "logger.h"
#include "settings.h"
using namespace std;
string HTTP_REQUEST(const std::string&,int);
void PostHTTP(const std::string& IP,const std::string& Fields);
int PlayerCount;
int Port;
int MaxPlayers;
string MapName;
string ServerName;
string Resource;
string ServerVersion;
void Heartbeat()
{
string UUID = HTTP_REQUEST("https://beamng-mp.com/new-server-startup",443);
@ -28,10 +22,10 @@ void Heartbeat()
{
//"name=daniel&project=curl"
//player maxplayers port map private version
PostHTTP("https://beamng-mp.com/heartbeat","d.uuid="+UUID+"&d.players="+to_string(PlayerCount)+"&d.maxplayers="+to_string(MaxPlayers)+"&d.port="
+ to_string(Port) + "&d.map=" + MapName + "&d.private=false"+"&d.version="+ServerVersion);
PostHTTP("https://beamng-mp.com/heartbeat","uuid="+UUID+"&players="+to_string(PlayerCount)+"&maxplayers="+to_string(MaxPlayers)+"&port="
+ to_string(UDPPort) + "&map=" + MapName + "&private="+Private+"&serverversion="+ServerVersion+"&clientversion="+ClientVersion+"&name="+ServerName);
std::this_thread::sleep_for (std::chrono::seconds(30));
std::this_thread::sleep_for (std::chrono::seconds(5));
}
}

View File

@ -6,6 +6,7 @@
#include <string>
#include <fstream>
#include "logger.h"
#include "settings.h"
#include <chrono>
#include <thread>
@ -17,28 +18,23 @@ void ServerMain(int Port, int MaxClients);
bool Debug = false;
void addToLog(basic_string<char> Data);
void HeartbeatInit();
static int Port = 30814;
static int MaxPlayers = 10;
static string MapName = "levels/gridmap/level.json";
static string ServerName = "BeamNG-MP FTW";
static string Resource = "/Resources";
static string ServerVersion = "0.1";
//Entry
int main() {
LogInit();
HeartbeatInit();
ParseConfig();
HeartbeatInit();
if(Debug){ //checks if debug is on
DebugData(); //Prints Debug Data
}
setLoggerLevel("ALL");
ServerMain(Port, MaxPlayers);
ServerMain(UDPPort, MaxPlayers);
}
void DebugData(){
cout << "Debug : true" << "\n";
cout << "Port : " << Port << "\n";
cout << "Port : " << UDPPort << "\n";
cout << "MaxPlayers : " << MaxPlayers << "\n";
cout << "MapName : " << MapName << "\n";
cout << "ServerName : " << ServerName << "\n";
@ -46,12 +42,12 @@ void DebugData(){
}
void SetMainValues(bool D, int P,int MP,string Name,string serverName,string filename){
Debug = D;
Port = P;
MapName = Name;
ServerName = serverName;
MaxPlayers = MP;
Resource = filename;
bool Debug = D;
int UDPPort = P;
string MapName = Name;
string ServerName = serverName;
int MaxPlayers = MP;
string Resource = filename;
}
void LogInit(){

23
src/settings.h Normal file
View File

@ -0,0 +1,23 @@
//
// Created by Mitch on 10/04/2020.
//
#ifndef BEAMMP_SERVER_SETTINGS_H
#define BEAMMP_SERVER_SETTINGS_H
// This is a declaration of your variable, which tells the linker this value
// is found elsewhere. Anyone who wishes to use it must include settings.h,
// either directly or indirectly.
static string MapName = "";
static string Private = "false";
static string UUID = "";
static int PlayerCount = 0;
static int MaxPlayers = 10;
static int UDPPort = 0;
static int TCPPort = 0;
static string ServerName = "BeamMP Server";
static string Resource = "/Resources";
static string ServerVersion = "0.1";
static string ClientVersion = "0.21";
#endif //BEAMMP_SERVER_SETTINGS_H