Skip to content

Commit

Permalink
minor fixes, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
lionkor authored and Anonymous-275 committed Jul 31, 2021
1 parent a1ca8e0 commit 3d0d5e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Application final {
// Causes all threads to finish up and exit gracefull gracefully
static void GracefullyShutdown();
static TConsole& Console() { return *mConsole; }
static std::string ServerVersion() { return "2.1.4"; }
static std::string ServerVersion() { return "2.2.0"; }
static std::string ClientVersion() { return "2.0"; }
static std::string PPS() { return mPPS; }
static void SetPPS(std::string NewPPS) { mPPS = NewPPS; }
Expand Down
4 changes: 2 additions & 2 deletions include/TConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ class TConfig {
public:
explicit TConfig();

bool Failed() const { return mFailed; }
[[nodiscard]] bool Failed() const { return mFailed; }

private:
void CreateConfigFile(std::string_view name);
void ParseFromFile(std::string_view name);
void PrintDebug();

void ParseOldFormat();

bool mFailed { false };
Expand Down
28 changes: 19 additions & 9 deletions src/TNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,19 +702,29 @@ void TNetwork::Parse(TClient& c, const std::string& Packet) {
}
}

void TNetwork::SendFile(TClient& c, const std::string& Name) {
info(c.GetName() + " requesting : " + Name.substr(Name.find_last_of('/')));
void TNetwork::SendFile(TClient& c, const std::string& UnsafeName) {
info(c.GetName() + " requesting : " + UnsafeName.substr(UnsafeName.find_last_of('/')));

if (!std::filesystem::exists(Name)) {
if (!fs::path(UnsafeName).has_filename()) {
if (!TCPSend(c, "CO")) {
// TODO: handle
}
warn("File " + Name + " could not be accessed!");
warn("File " + UnsafeName + " is not a file!");
return;
} else {
if (!TCPSend(c, "AG")) {
}
auto FileName = fs::path(UnsafeName).filename().string();
FileName = Application::Settings.Resource + "/Client/" + FileName;

if (!std::filesystem::exists(FileName)) {
if (!TCPSend(c, "CO")) {
// TODO: handle
}
warn("File " + UnsafeName + " could not be accessed!");
return;
}

if (!TCPSend(c, "AG")) {
// TODO: handle
}

///Wait for connections
Expand All @@ -731,14 +741,14 @@ void TNetwork::SendFile(TClient& c, const std::string& Name) {
return;
}

size_t Size = size_t(std::filesystem::file_size(Name)), MSize = Size / 2;
size_t Size = size_t(std::filesystem::file_size(FileName)), MSize = Size / 2;

std::thread SplitThreads[2] {
std::thread([&] {
SplitLoad(c, 0, MSize, false, Name);
SplitLoad(c, 0, MSize, false, FileName);
}),
std::thread([&] {
SplitLoad(c, MSize, Size, true, Name);
SplitLoad(c, MSize, Size, true, FileName);
})
};

Expand Down
2 changes: 1 addition & 1 deletion src/TResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TResourceManager::TResourceManager() {
++i;
File = File.substr(i,pos-i);
}
mTrimmedList += File + ';';
mTrimmedList += "/" + fs::path(File).filename().string() + ';';
mFileSizes += std::to_string(size_t(fs::file_size(entry.path()))) + ';';
mMaxModSize += size_t(fs::file_size(entry.path()));
mModsLoaded++;
Expand Down

0 comments on commit 3d0d5e9

Please sign in to comment.