mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-18 14:19:57 +00:00
Reformat to clang-format
This commit is contained in:
@@ -8,10 +8,11 @@
|
||||
|
||||
class HTTP {
|
||||
public:
|
||||
static bool Download(const std::string &IP, const std::string &Path);
|
||||
static bool Download(const std::string& IP, const std::string& Path);
|
||||
static std::string Post(const std::string& IP, const std::string& Fields);
|
||||
static std::string Get(const std::string &IP);
|
||||
static std::string Get(const std::string& IP);
|
||||
static bool ProgressBar(size_t c, size_t t);
|
||||
|
||||
public:
|
||||
static bool isDownload;
|
||||
};
|
||||
@@ -6,4 +6,3 @@
|
||||
#pragma once
|
||||
#include <nlohmann/json.hpp>
|
||||
using Json = nlohmann::json;
|
||||
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
|
||||
#pragma once
|
||||
#include "Memory/IPC.h"
|
||||
#include <filesystem>
|
||||
#include "Server.h"
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
struct VersionParser {
|
||||
@@ -21,10 +20,11 @@ struct VersionParser {
|
||||
};
|
||||
|
||||
class Launcher {
|
||||
public: //constructors
|
||||
public: // constructors
|
||||
Launcher(int argc, char* argv[]);
|
||||
~Launcher();
|
||||
public: //available functions
|
||||
|
||||
public: // available functions
|
||||
static void StaticAbort(Launcher* Instance = nullptr);
|
||||
std::string Login(const std::string& fields);
|
||||
void SendIPC(const std::string& Data, bool core = true);
|
||||
@@ -35,7 +35,8 @@ public: //available functions
|
||||
void LaunchGame();
|
||||
void CheckKey();
|
||||
void SetupMOD();
|
||||
public: //Getters and Setters
|
||||
|
||||
public: // Getters and Setters
|
||||
void setDiscordMessage(const std::string& message);
|
||||
static void setExit(bool exit) noexcept;
|
||||
const std::string& getFullVersion();
|
||||
@@ -46,7 +47,7 @@ public: //Getters and Setters
|
||||
const std::string& getVersion();
|
||||
static bool getExit() noexcept;
|
||||
|
||||
private: //functions
|
||||
private: // functions
|
||||
void HandleIPC(const std::string& Data);
|
||||
std::string GetLocalAppdata();
|
||||
void UpdatePresence();
|
||||
@@ -59,32 +60,34 @@ private: //functions
|
||||
void Relaunch();
|
||||
void ListenIPC();
|
||||
void Abort();
|
||||
private: //variables
|
||||
uint32_t GamePID{0};
|
||||
|
||||
private: // variables
|
||||
uint32_t GamePID { 0 };
|
||||
bool EnableUI = true;
|
||||
int64_t DiscordTime{};
|
||||
int64_t DiscordTime {};
|
||||
bool LoginAuth = false;
|
||||
fs::path CurrentPath{};
|
||||
std::string BeamRoot{};
|
||||
std::string UserRole{};
|
||||
std::string PublicKey{};
|
||||
std::thread IPCSystem{};
|
||||
std::thread DiscordRPC{};
|
||||
std::string MPUserPath{};
|
||||
std::string BeamVersion{};
|
||||
std::string BeamUserPath{};
|
||||
std::string DiscordMessage{};
|
||||
std::string Version{"2.0"};
|
||||
Server ServerHandler{this};
|
||||
std::string TargetBuild{"default"};
|
||||
static inline std::atomic<bool> Shutdown{false}, Exit{false};
|
||||
std::string FullVersion{Version + ".99"};
|
||||
VersionParser SupportedVersion{"0.25.4.0"};
|
||||
std::unique_ptr<IPC> IPCToGame{};
|
||||
std::unique_ptr<IPC> IPCFromGame{};
|
||||
fs::path CurrentPath {};
|
||||
std::string BeamRoot {};
|
||||
std::string UserRole {};
|
||||
std::string PublicKey {};
|
||||
std::thread IPCSystem {};
|
||||
std::thread DiscordRPC {};
|
||||
std::string MPUserPath {};
|
||||
std::string BeamVersion {};
|
||||
std::string BeamUserPath {};
|
||||
std::string DiscordMessage {};
|
||||
std::string Version { "2.0" };
|
||||
Server ServerHandler { this };
|
||||
std::string TargetBuild { "default" };
|
||||
static inline std::atomic<bool> Shutdown { false }, Exit { false };
|
||||
std::string FullVersion { Version + ".99" };
|
||||
VersionParser SupportedVersion { "0.25.4.0" };
|
||||
std::unique_ptr<IPC> IPCToGame {};
|
||||
std::unique_ptr<IPC> IPCFromGame {};
|
||||
};
|
||||
|
||||
class ShutdownException : public std::runtime_error {
|
||||
public:
|
||||
explicit ShutdownException(const std::string& message): runtime_error(message){};
|
||||
explicit ShutdownException(const std::string& message)
|
||||
: runtime_error(message) {};
|
||||
};
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
///
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
struct sockaddr_in;
|
||||
class Launcher;
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
Server() = delete;
|
||||
explicit Server(Launcher* Instance);
|
||||
~Server();
|
||||
|
||||
public:
|
||||
void ServerSend(std::string Data, bool Rel);
|
||||
void Connect(const std::string& Data);
|
||||
@@ -27,11 +28,12 @@ public:
|
||||
bool Terminated();
|
||||
int getPing() const;
|
||||
void Close();
|
||||
|
||||
private:
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> PingStart, PingEnd;
|
||||
std::string MultiDownload(uint64_t DSock, uint64_t Size, const std::string& Name);
|
||||
void AsyncUpdate(uint64_t& Rcv,uint64_t Size,const std::string& Name);
|
||||
std::atomic<bool> Terminate{false}, ModLoaded{false};
|
||||
void AsyncUpdate(uint64_t& Rcv, uint64_t Size, const std::string& Name);
|
||||
std::atomic<bool> Terminate { false }, ModLoaded { false };
|
||||
char* TCPRcvRaw(uint64_t Sock, uint64_t& GRcv, uint64_t Size);
|
||||
std::string GetAddress(const std::string& Data);
|
||||
void InvalidResource(const std::string& File);
|
||||
@@ -54,21 +56,21 @@ private:
|
||||
uint64_t TCPSocket = -1;
|
||||
uint64_t UDPSocket = -1;
|
||||
void WaitForConfirm();
|
||||
std::string UStatus{};
|
||||
std::string MStatus{};
|
||||
std::string ModList{};
|
||||
std::string UStatus {};
|
||||
std::string MStatus {};
|
||||
std::string ModList {};
|
||||
void TCPClientMain();
|
||||
void SyncResources();
|
||||
std::string TCPRcv();
|
||||
uint64_t InitDSock();
|
||||
std::string Auth();
|
||||
std::string IP{};
|
||||
std::string IP {};
|
||||
void UDPClient();
|
||||
void PingLoop();
|
||||
int ClientID{0};
|
||||
int ClientID { 0 };
|
||||
void UDPMain();
|
||||
void UDPRcv();
|
||||
void Abort();
|
||||
int Port{0};
|
||||
int Ping{0};
|
||||
int Port { 0 };
|
||||
int Ping { 0 };
|
||||
};
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
//
|
||||
// Created by Anonymous275 on 24/07/22.
|
||||
//
|
||||
///
|
||||
/// Created by Anonymous275 on 7/26/22
|
||||
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
|
||||
///
|
||||
|
||||
#pragma once
|
||||
#include <semaphore>
|
||||
#include <queue>
|
||||
#include <semaphore>
|
||||
|
||||
template <class T, size_t Size>
|
||||
class atomic_queue {
|
||||
public:
|
||||
bool try_pop(T& val) {
|
||||
lock_guard guard(semaphore);
|
||||
if(queue.empty())return false;
|
||||
if (queue.empty())
|
||||
return false;
|
||||
val = queue.front();
|
||||
queue.pop();
|
||||
full.release();
|
||||
@@ -33,24 +35,27 @@ public:
|
||||
lock_guard guard(semaphore);
|
||||
return queue.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
void check_full() {
|
||||
if(size() >= Size) {
|
||||
if (size() >= Size) {
|
||||
full.acquire();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
struct lock_guard {
|
||||
explicit lock_guard(std::binary_semaphore& lock) : lock(lock){
|
||||
explicit lock_guard(std::binary_semaphore& lock)
|
||||
: lock(lock) {
|
||||
lock.acquire();
|
||||
}
|
||||
~lock_guard() {
|
||||
lock.release();
|
||||
}
|
||||
|
||||
private:
|
||||
std::binary_semaphore& lock;
|
||||
};
|
||||
std::binary_semaphore semaphore{1}, full{0};
|
||||
std::queue<T> queue{};
|
||||
std::binary_semaphore semaphore { 1 }, full { 0 };
|
||||
std::queue<T> queue {};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user