mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-06-17 23:30:53 +00:00
Working Mod Sync
This commit is contained in:
@@ -16,7 +16,8 @@ int ParseAndSend(SOCKET Client, std::string Data){
|
|||||||
bool FileSent = true;
|
bool FileSent = true;
|
||||||
switch (ID){
|
switch (ID){
|
||||||
case 'a' :
|
case 'a' :
|
||||||
Response = FileList;
|
Response = FileList+FileSizes;
|
||||||
|
if(Response.empty())Response = " ";
|
||||||
break;
|
break;
|
||||||
case 'b' :
|
case 'b' :
|
||||||
FileSent = false;
|
FileSent = false;
|
||||||
@@ -35,9 +36,10 @@ int ParseAndSend(SOCKET Client, std::string Data){
|
|||||||
f.seekg(0, std::ios_base::beg);
|
f.seekg(0, std::ios_base::beg);
|
||||||
f.read(&Response[0], Size);
|
f.read(&Response[0], Size);
|
||||||
f.close();
|
f.close();
|
||||||
}else{f.close();}
|
}else f.close();
|
||||||
|
|
||||||
if(DataSent != Size){
|
if(DataSent != Size){
|
||||||
|
Packet.clear();
|
||||||
if((Size-DataSent) < 65535){
|
if((Size-DataSent) < 65535){
|
||||||
Packet = Response.substr(Prev,(Size-DataSent));
|
Packet = Response.substr(Prev,(Size-DataSent));
|
||||||
DataSent += (Size-DataSent);
|
DataSent += (Size-DataSent);
|
||||||
@@ -48,14 +50,15 @@ int ParseAndSend(SOCKET Client, std::string Data){
|
|||||||
}
|
}
|
||||||
Prev = DataSent;
|
Prev = DataSent;
|
||||||
}else{
|
}else{
|
||||||
Size = DataSent = Prev = 0;
|
Size = 0;
|
||||||
Response = "End of file";
|
DataSent = 0;
|
||||||
|
Prev = 0;
|
||||||
FileSent = true;
|
FileSent = true;
|
||||||
Packet.clear();
|
Packet.clear();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
FileSent = true;
|
FileSent = true;
|
||||||
Response = "Cannot Open File " + FLocation;
|
Response = "Cannot Open";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -2,6 +2,7 @@
|
|||||||
/// Created by Anonymous275 on 4/11/2020
|
/// Created by Anonymous275 on 4/11/2020
|
||||||
///
|
///
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@@ -9,6 +10,7 @@
|
|||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
std::string FileList;
|
std::string FileList;
|
||||||
|
std::string FileSizes;
|
||||||
|
|
||||||
void HandleResources(const std::string& path){
|
void HandleResources(const std::string& path){
|
||||||
struct stat info{};
|
struct stat info{};
|
||||||
@@ -16,7 +18,13 @@ void HandleResources(const std::string& path){
|
|||||||
_wmkdir(L"Resources");
|
_wmkdir(L"Resources");
|
||||||
}
|
}
|
||||||
for (const auto & entry : fs::directory_iterator(path)){
|
for (const auto & entry : fs::directory_iterator(path)){
|
||||||
FileList += entry.path().string() + ";";
|
int pos = entry.path().string().find(".zip");
|
||||||
|
if(pos != std::string::npos){
|
||||||
|
if(entry.path().string().length() - pos == 4){
|
||||||
|
FileList += entry.path().string() + ";";
|
||||||
|
FileSizes += std::to_string(fs::file_size(entry.path()))+";";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::replace(FileList.begin(),FileList.end(),'\\','/');
|
std::replace(FileList.begin(),FileList.end(),'\\','/');
|
||||||
}
|
}
|
||||||
@@ -12,3 +12,4 @@ extern std::string Resource;
|
|||||||
extern std::string ServerVersion;
|
extern std::string ServerVersion;
|
||||||
extern std::string ClientVersion;
|
extern std::string ClientVersion;
|
||||||
extern std::string FileList;
|
extern std::string FileList;
|
||||||
|
extern std::string FileSizes;
|
||||||
|
|||||||
Reference in New Issue
Block a user