mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-02 15:55:30 +00:00
i broke it some what sorry Anon
This commit is contained in:
parent
388cffbe01
commit
9bdec9e5f8
@ -6,5 +6,5 @@ include_directories(${PROJECT_SOURCE_DIR}/curl)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
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)
|
target_link_libraries(BeamMP-Server winmm ws2_32 libcurl_a)
|
@ -6,20 +6,14 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include "logger.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
string HTTP_REQUEST(const std::string&,int);
|
string HTTP_REQUEST(const std::string&,int);
|
||||||
void PostHTTP(const std::string& IP,const std::string& Fields);
|
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()
|
void Heartbeat()
|
||||||
{
|
{
|
||||||
string UUID = HTTP_REQUEST("https://beamng-mp.com/new-server-startup",443);
|
string UUID = HTTP_REQUEST("https://beamng-mp.com/new-server-startup",443);
|
||||||
@ -28,10 +22,10 @@ void Heartbeat()
|
|||||||
{
|
{
|
||||||
//"name=daniel&project=curl"
|
//"name=daniel&project=curl"
|
||||||
//player maxplayers port map private version
|
//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="
|
PostHTTP("https://beamng-mp.com/heartbeat","uuid="+UUID+"&players="+to_string(PlayerCount)+"&maxplayers="+to_string(MaxPlayers)+"&port="
|
||||||
+ to_string(Port) + "&d.map=" + MapName + "&d.private=false"+"&d.version="+ServerVersion);
|
+ 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
src/main.cpp
26
src/main.cpp
@ -6,6 +6,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "settings.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
@ -17,28 +18,23 @@ void ServerMain(int Port, int MaxClients);
|
|||||||
bool Debug = false;
|
bool Debug = false;
|
||||||
void addToLog(basic_string<char> Data);
|
void addToLog(basic_string<char> Data);
|
||||||
void HeartbeatInit();
|
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
|
//Entry
|
||||||
int main() {
|
int main() {
|
||||||
LogInit();
|
LogInit();
|
||||||
HeartbeatInit();
|
|
||||||
ParseConfig();
|
ParseConfig();
|
||||||
|
HeartbeatInit();
|
||||||
if(Debug){ //checks if debug is on
|
if(Debug){ //checks if debug is on
|
||||||
DebugData(); //Prints Debug Data
|
DebugData(); //Prints Debug Data
|
||||||
}
|
}
|
||||||
setLoggerLevel("ALL");
|
setLoggerLevel("ALL");
|
||||||
ServerMain(Port, MaxPlayers);
|
ServerMain(UDPPort, MaxPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DebugData(){
|
void DebugData(){
|
||||||
cout << "Debug : true" << "\n";
|
cout << "Debug : true" << "\n";
|
||||||
cout << "Port : " << Port << "\n";
|
cout << "Port : " << UDPPort << "\n";
|
||||||
cout << "MaxPlayers : " << MaxPlayers << "\n";
|
cout << "MaxPlayers : " << MaxPlayers << "\n";
|
||||||
cout << "MapName : " << MapName << "\n";
|
cout << "MapName : " << MapName << "\n";
|
||||||
cout << "ServerName : " << ServerName << "\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){
|
void SetMainValues(bool D, int P,int MP,string Name,string serverName,string filename){
|
||||||
Debug = D;
|
bool Debug = D;
|
||||||
Port = P;
|
int UDPPort = P;
|
||||||
MapName = Name;
|
string MapName = Name;
|
||||||
ServerName = serverName;
|
string ServerName = serverName;
|
||||||
MaxPlayers = MP;
|
int MaxPlayers = MP;
|
||||||
Resource = filename;
|
string Resource = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogInit(){
|
void LogInit(){
|
||||||
|
23
src/settings.h
Normal file
23
src/settings.h
Normal 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
|
Loading…
x
Reference in New Issue
Block a user