x86 support

This commit is contained in:
Anonymous275 2021-03-04 22:44:33 +02:00
parent 9a74434bbb
commit 776ddcbbef
6 changed files with 13 additions and 13 deletions

View File

@ -23,7 +23,7 @@ inline void CloseSocketProper(int socket) {
#ifdef WIN32 #ifdef WIN32
#include <conio.h> #include <conio.h>
#include <winsock2.h> #include <winsock2.h>
inline void CloseSocketProper(u_int64 socket) { inline void CloseSocketProper(SOCKET socket) {
shutdown(socket, SD_BOTH); shutdown(socket, SD_BOTH);
closesocket(socket); closesocket(socket);
} }

View File

@ -6,14 +6,14 @@ class TResourceManager {
public: public:
TResourceManager(); TResourceManager();
[[nodiscard]] uint64_t MaxModSize() const { return mMaxModSize; } [[nodiscard]] size_t MaxModSize() const { return mMaxModSize; }
[[nodiscard]] std::string FileList() const { return mFileList; } [[nodiscard]] std::string FileList() const { return mFileList; }
[[nodiscard]] std::string TrimmedList() const { return mTrimmedList; } [[nodiscard]] std::string TrimmedList() const { return mTrimmedList; }
[[nodiscard]] std::string FileSizes() const { return mFileSizes; } [[nodiscard]] std::string FileSizes() const { return mFileSizes; }
[[nodiscard]] int ModsLoaded() const { return mModsLoaded; } [[nodiscard]] int ModsLoaded() const { return mModsLoaded; }
private: private:
uint64_t mMaxModSize = 0; size_t mMaxModSize = 0;
std::string mFileSizes; std::string mFileSizes;
std::string mFileList; std::string mFileList;
std::string mTrimmedList; std::string mTrimmedList;

View File

@ -50,5 +50,5 @@ private:
void Parse(TClient& c, const std::string& Packet); void Parse(TClient& c, const std::string& Packet);
void SendFile(TClient& c, const std::string& Name); void SendFile(TClient& c, const std::string& Name);
static bool TCPSendRaw(SOCKET C, char* Data, int32_t Size); static bool TCPSendRaw(SOCKET C, char* Data, int32_t Size);
static void SplitLoad(TClient& c, int64_t Sent, int64_t Size, bool D, const std::string& Name); static void SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std::string& Name);
}; };

View File

@ -20,8 +20,8 @@ TResourceManager::TResourceManager() {
File = File.substr(i,pos-i); File = File.substr(i,pos-i);
} }
mTrimmedList += File + ';'; mTrimmedList += File + ';';
mFileSizes += std::to_string(uint64_t(fs::file_size(entry.path()))) + ';'; mFileSizes += std::to_string(size_t(fs::file_size(entry.path()))) + ';';
mMaxModSize += uint64_t(fs::file_size(entry.path())); mMaxModSize += size_t(fs::file_size(entry.path()));
mModsLoaded++; mModsLoaded++;
} }
} }

View File

@ -443,7 +443,7 @@ void TTCPServer::SendFile(TClient& c, const std::string& Name) {
return; return;
} }
int64_t Size = std::filesystem::file_size(Name), MSize = Size / 2; size_t Size = size_t(std::filesystem::file_size(Name)), MSize = Size / 2;
std::thread SplitThreads[2] { std::thread SplitThreads[2] {
std::thread([&] { std::thread([&] {
@ -461,9 +461,9 @@ void TTCPServer::SendFile(TClient& c, const std::string& Name) {
} }
} }
void TTCPServer::SplitLoad(TClient& c, int64_t Sent, int64_t Size, bool D, const std::string& Name) { void TTCPServer::SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std::string& Name) {
std::ifstream f(Name.c_str(), std::ios::binary); std::ifstream f(Name.c_str(), std::ios::binary);
int32_t Split = 0x7735940; //125MB uint32_t Split = 0x7735940; //125MB
char* Data; char* Data;
if (Size > Split) if (Size > Split)
Data = new char[Split]; Data = new char[Split];
@ -476,7 +476,7 @@ void TTCPServer::SplitLoad(TClient& c, int64_t Sent, int64_t Size, bool D, const
TCPSock = c.GetTCPSock(); TCPSock = c.GetTCPSock();
info("Split load Socket " + std::to_string(TCPSock)); info("Split load Socket " + std::to_string(TCPSock));
while (c.GetStatus() > -1 && Sent < Size) { while (c.GetStatus() > -1 && Sent < Size) {
int64_t Diff = Size - Sent; size_t Diff = Size - Sent;
if (Diff > Split) { if (Diff > Split) {
f.seekg(Sent, std::ios_base::beg); f.seekg(Sent, std::ios_base::beg);
f.read(Data, Split); f.read(Data, Split);
@ -502,9 +502,9 @@ void TTCPServer::SplitLoad(TClient& c, int64_t Sent, int64_t Size, bool D, const
} }
bool TTCPServer::TCPSendRaw(SOCKET C, char* Data, int32_t Size) { bool TTCPServer::TCPSendRaw(SOCKET C, char* Data, int32_t Size) {
int64_t Sent = 0; intmax_t Sent = 0;
do { do {
int64_t Temp = send(C, &Data[Sent], int(Size - Sent), 0); intmax_t Temp = send(C, &Data[Sent], int(Size - Sent), 0);
if (Temp < 1) { if (Temp < 1) {
info("Socket Closed! " + std::to_string(C)); info("Socket Closed! " + std::to_string(C));
CloseSocketProper(C); CloseSocketProper(C);

View File

@ -162,7 +162,7 @@ std::string TUDPServer::UDPRcvFromClient(sockaddr_in& client) const {
size_t clientLength = sizeof(client); size_t clientLength = sizeof(client);
std::array<char, 1024> Ret {}; std::array<char, 1024> Ret {};
#ifdef WIN32 #ifdef WIN32
int64_t Rcv = recvfrom(mUDPSock, Ret.data(), int(Ret.size()), 0, (sockaddr*)&client, (int*)&clientLength); auto Rcv = recvfrom(mUDPSock, Ret.data(), int(Ret.size()), 0, (sockaddr*)&client, (int*)&clientLength);
#else // unix #else // unix
int64_t Rcv = recvfrom(mUDPSock, Ret.data(), Ret.size(), 0, (sockaddr*)&client, (socklen_t*)&clientLength); int64_t Rcv = recvfrom(mUDPSock, Ret.data(), Ret.size(), 0, (sockaddr*)&client, (socklen_t*)&clientLength);
#endif // WIN32 #endif // WIN32