mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-04 14:56:24 +00:00
Compare commits
10 Commits
v2.2.0
...
add-warnin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e5fe80202 | ||
|
|
7ff4681263 | ||
|
|
3be1262b07 | ||
|
|
cfcabf31a4 | ||
|
|
5714c3de76 | ||
|
|
12711d77c7 | ||
|
|
e08a4de6db | ||
|
|
acd5f4ed09 | ||
|
|
c4e7b9a919 | ||
|
|
3db1f6773e |
@@ -13,6 +13,8 @@ void NetReset();
|
|||||||
extern bool Dev;
|
extern bool Dev;
|
||||||
extern int ping;
|
extern int ping;
|
||||||
|
|
||||||
|
extern bool ModWarningConfirmed;
|
||||||
|
|
||||||
[[noreturn]] void CoreNetwork();
|
[[noreturn]] void CoreNetwork();
|
||||||
extern int ProxyPort;
|
extern int ProxyPort;
|
||||||
extern int ClientID;
|
extern int ClientID;
|
||||||
@@ -46,3 +48,4 @@ void TCPClientMain(const std::string& IP,int Port);
|
|||||||
void UDPClientMain(const std::string& IP,int Port);
|
void UDPClientMain(const std::string& IP,int Port);
|
||||||
void TCPGameServer(const std::string& IP, int Port);
|
void TCPGameServer(const std::string& IP, int Port);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ bool IsAllowedLink(const std::string& Link) {
|
|||||||
return std::regex_search(Link,link_match, link_pattern) && link_match.position() == 0;
|
return std::regex_search(Link,link_match, link_pattern) && link_match.position() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ModWarningConfirmed = false;
|
||||||
|
|
||||||
void Parse(std::string Data,SOCKET CSocket){
|
void Parse(std::string Data,SOCKET CSocket){
|
||||||
char Code = Data.at(0), SubCode = 0;
|
char Code = Data.at(0), SubCode = 0;
|
||||||
if(Data.length() > 1)SubCode = Data.at(1);
|
if(Data.length() > 1)SubCode = Data.at(1);
|
||||||
@@ -87,6 +89,17 @@ void Parse(std::string Data,SOCKET CSocket){
|
|||||||
}
|
}
|
||||||
Data.clear();
|
Data.clear();
|
||||||
break;
|
break;
|
||||||
|
// response to "WMODS_FOUND" message, either Y (yes ok) or N (no)
|
||||||
|
case 'W': {
|
||||||
|
if (SubCode == 'Y') {
|
||||||
|
ModWarningConfirmed = true;
|
||||||
|
} else if (SubCode == 'N') {
|
||||||
|
ModWarningConfirmed = false;
|
||||||
|
NetReset();
|
||||||
|
Terminate = true;
|
||||||
|
TCPTerminate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
case 'P':
|
case 'P':
|
||||||
Data = Code + std::to_string(ProxyPort);
|
Data = Code + std::to_string(ProxyPort);
|
||||||
break;
|
break;
|
||||||
@@ -138,7 +151,7 @@ void Parse(std::string Data,SOCKET CSocket){
|
|||||||
if (!UserRole.empty()) {
|
if (!UserRole.empty()) {
|
||||||
Auth["role"] = UserRole;
|
Auth["role"] = UserRole;
|
||||||
}
|
}
|
||||||
Data = Auth.dump();
|
Data = "N" + Auth.dump();
|
||||||
}else{
|
}else{
|
||||||
Data = "N" + Login(Data.substr(Data.find(':') + 1));
|
Data = "N" + Login(Data.substr(Data.find(':') + 1));
|
||||||
}
|
}
|
||||||
@@ -205,6 +218,10 @@ void localRes(){
|
|||||||
}
|
}
|
||||||
ConfList = new std::set<std::string>;
|
ConfList = new std::set<std::string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t TheClientSocket;
|
||||||
|
|
||||||
void CoreMain() {
|
void CoreMain() {
|
||||||
debug("Core Network on start!");
|
debug("Core Network on start!");
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
@@ -253,6 +270,7 @@ void CoreMain() {
|
|||||||
error("(Core) accept failed with error: " + std::to_string(WSAGetLastError()));
|
error("(Core) accept failed with error: " + std::to_string(WSAGetLastError()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
TheClientSocket = CSocket;
|
||||||
localRes();
|
localRes();
|
||||||
info("Game Connected!");
|
info("Game Connected!");
|
||||||
GameHandler(CSocket);
|
GameHandler(CSocket);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
extern SOCKET TheClientSocket;
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
std::string ListOfMods;
|
std::string ListOfMods;
|
||||||
std::vector<std::string> Split(const std::string& String,const std::string& delimiter){
|
std::vector<std::string> Split(const std::string& String,const std::string& delimiter){
|
||||||
@@ -221,6 +223,23 @@ void SyncResources(SOCKET Sock){
|
|||||||
std::string Ret = Auth(Sock);
|
std::string Ret = Auth(Sock);
|
||||||
if(Ret.empty())return;
|
if(Ret.empty())return;
|
||||||
|
|
||||||
|
ModWarningConfirmed = false;
|
||||||
|
Terminate = false;
|
||||||
|
|
||||||
|
std::string Data = "WMODS_FOUND";
|
||||||
|
send(TheClientSocket, (Data + "\n").c_str(), int(Data.size())+1, 0);
|
||||||
|
|
||||||
|
while (!Terminate && !ModWarningConfirmed) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ModWarningConfirmed) {
|
||||||
|
UlStatus = "UlMods rejected!";
|
||||||
|
info("Mods rejected by user!");
|
||||||
|
// game has already cancelled by now
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
info("Checking Resources...");
|
info("Checking Resources...");
|
||||||
CheckForDir();
|
CheckForDir();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user