mirror of https://github.com/OpenTTD/OpenTTD
Codechange: SaveFilter::Write should have a const buffer
parent
8db08da148
commit
3b6fe07732
|
@ -138,7 +138,7 @@ struct PacketWriter : SaveFilter {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(const byte *buf, size_t size) override
|
||||
{
|
||||
/* We want to abort the saving when the socket is closed. */
|
||||
if (this->cs == nullptr) SlError(STR_NETWORK_ERROR_LOSTCONNECTION);
|
||||
|
@ -147,7 +147,7 @@ struct PacketWriter : SaveFilter {
|
|||
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
|
||||
byte *bufe = buf + size;
|
||||
const byte *bufe = buf + size;
|
||||
while (buf != bufe) {
|
||||
size_t written = this->current->Send_bytes(buf, bufe);
|
||||
buf += written;
|
||||
|
|
|
@ -2212,7 +2212,7 @@ struct FileWriter : SaveFilter {
|
|||
this->Finish();
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(const byte *buf, size_t size) override
|
||||
{
|
||||
/* We're in the process of shutting down, i.e. in "failure" mode. */
|
||||
if (this->file == nullptr) return;
|
||||
|
@ -2295,7 +2295,7 @@ struct LZOSaveFilter : SaveFilter {
|
|||
if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(const byte *buf, size_t size) override
|
||||
{
|
||||
const lzo_bytep in = buf;
|
||||
/* Buffer size is from the LZO docs plus the chunk header size. */
|
||||
|
@ -2350,7 +2350,7 @@ struct NoCompSaveFilter : SaveFilter {
|
|||
{
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(const byte *buf, size_t size) override
|
||||
{
|
||||
this->chain->Write(buf, size);
|
||||
}
|
||||
|
@ -2435,10 +2435,10 @@ struct ZlibSaveFilter : SaveFilter {
|
|||
* @param len Amount of bytes to write.
|
||||
* @param mode Mode for deflate.
|
||||
*/
|
||||
void WriteLoop(byte *p, size_t len, int mode)
|
||||
void WriteLoop(const byte *p, size_t len, int mode)
|
||||
{
|
||||
uint n;
|
||||
this->z.next_in = p;
|
||||
this->z.next_in = const_cast<byte *>(p);
|
||||
this->z.avail_in = (uInt)len;
|
||||
do {
|
||||
this->z.next_out = this->fwrite_buf;
|
||||
|
@ -2463,7 +2463,7 @@ struct ZlibSaveFilter : SaveFilter {
|
|||
} while (this->z.avail_in || !this->z.avail_out);
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(const byte *buf, size_t size) override
|
||||
{
|
||||
this->WriteLoop(buf, size, 0);
|
||||
}
|
||||
|
@ -2562,7 +2562,7 @@ struct LZMASaveFilter : SaveFilter {
|
|||
* @param len Amount of bytes to write.
|
||||
* @param action Action for lzma_code.
|
||||
*/
|
||||
void WriteLoop(byte *p, size_t len, lzma_action action)
|
||||
void WriteLoop(const byte *p, size_t len, lzma_action action)
|
||||
{
|
||||
size_t n;
|
||||
this->lzma.next_in = p;
|
||||
|
@ -2582,7 +2582,7 @@ struct LZMASaveFilter : SaveFilter {
|
|||
} while (this->lzma.avail_in || !this->lzma.avail_out);
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(const byte *buf, size_t size) override
|
||||
{
|
||||
this->WriteLoop(buf, size, LZMA_RUN);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ struct SaveFilter {
|
|||
* @param buf The bytes to write.
|
||||
* @param len The number of bytes to write.
|
||||
*/
|
||||
virtual void Write(byte *buf, size_t len) = 0;
|
||||
virtual void Write(const byte *buf, size_t len) = 0;
|
||||
|
||||
/**
|
||||
* Prepare everything to finish writing the savegame.
|
||||
|
|
Loading…
Reference in New Issue