mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 12:33:17 +01:00
Use stream for chat log
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
enum
|
||||
{
|
||||
FILE_MODE_OPEN,
|
||||
FILE_MODE_WRITE
|
||||
FILE_MODE_WRITE,
|
||||
FILE_MODE_APPEND,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -61,6 +62,11 @@ public:
|
||||
_canRead = true;
|
||||
_canWrite = true;
|
||||
break;
|
||||
case FILE_MODE_APPEND:
|
||||
mode = "a";
|
||||
_canRead = false;
|
||||
_canWrite = true;
|
||||
break;
|
||||
default:
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -807,10 +807,11 @@ void Network::AppendChatLog(const utf8 *text)
|
||||
utf8 directory[MAX_PATH];
|
||||
Path::GetDirectory(directory, sizeof(directory), chatLogPath);
|
||||
if (platform_ensure_directory_exists(directory)) {
|
||||
_chatLogStream = SDL_RWFromFile(chatLogPath, "a");
|
||||
if (_chatLogStream != nullptr) {
|
||||
utf8 buffer[256];
|
||||
try
|
||||
{
|
||||
_chatLogStream = new FileStream(chatLogPath, FILE_MODE_APPEND);
|
||||
|
||||
utf8 buffer[256];
|
||||
time_t timer;
|
||||
struct tm * tmInfo;
|
||||
time(&timer);
|
||||
@@ -821,8 +822,12 @@ void Network::AppendChatLog(const utf8 *text)
|
||||
utf8_remove_formatting(buffer, false);
|
||||
String::Append(buffer, sizeof(buffer), PLATFORM_NEWLINE);
|
||||
|
||||
SDL_RWwrite(_chatLogStream, buffer, strlen(buffer), 1);
|
||||
SDL_RWclose(_chatLogStream);
|
||||
_chatLogStream->Write(buffer, strlen(buffer));
|
||||
delete _chatLogStream;
|
||||
_chatLogStream = nullptr;
|
||||
}
|
||||
catch (const Exception &)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ extern "C" {
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <openssl/evp.h>
|
||||
#include <SDL.h>
|
||||
#include "../core/Json.hpp"
|
||||
#include "../core/Nullable.hpp"
|
||||
#include "NetworkConnection.h"
|
||||
@@ -214,7 +213,7 @@ private:
|
||||
INetworkServerAdvertiser * _advertiser = nullptr;
|
||||
uint32 server_connect_time = 0;
|
||||
uint8 default_group = 0;
|
||||
SDL_RWops *_chatLogStream = nullptr;
|
||||
IStream * _chatLogStream = nullptr;
|
||||
std::string _chatLogPath;
|
||||
uint32 game_commands_processed_this_tick = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user