2021-12-05 17:54:36 +00:00
|
|
|
#include "PacketUtils.h"
|
|
|
|
#include <fstream>
|
2023-10-21 23:31:55 +00:00
|
|
|
#include "Logger.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#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.
|
2023-10-21 23:31:55 +00:00
|
|
|
if (!Game::logger->GetLogToConsole()) return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
std::string path = "packets/" + filename;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
std::ofstream file(path, std::ios::binary);
|
|
|
|
if (!file.is_open()) return;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
file.write(data, length);
|
|
|
|
file.close();
|
|
|
|
}
|