DarkflameServer/dNet/PacketUtils.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
522 B
C++
Raw Normal View History

#include "PacketUtils.h"
#include <fstream>
#include "Logger.h"
#include "Game.h"
//! Saves a packet to the filesystem
void PacketUtils::SavePacket(const std::string& filename, const char* data, size_t length) {
//If we don't log to the console, don't save the bin files either. This takes up a lot of time.
if (!Game::logger->GetLogToConsole()) return;
std::string path = "packets/" + filename;
2022-07-28 13:39:57 +00:00
std::ofstream file(path, std::ios::binary);
if (!file.is_open()) return;
2022-07-28 13:39:57 +00:00
file.write(data, length);
file.close();
}