forked from rosebudai/OpenRCT2-Web
Replace Memory::Copy with std::copy
This commit is contained in:
1 parent
bb8b6a3f68
commit
0c71855769
19 files changed
+72
-85
No files matched your search
@@ -14,6 +14,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -1006,7 +1007,7 @@ extern "C"
|
|||||||
auto resolutions = GetContext()->GetUiContext()->GetFullscreenResolutions();
|
auto resolutions = GetContext()->GetUiContext()->GetFullscreenResolutions();
|
||||||
sint32 count = (sint32)resolutions.size();
|
sint32 count = (sint32)resolutions.size();
|
||||||
*outResolutions = Memory::AllocateArray<Resolution>(count);
|
*outResolutions = Memory::AllocateArray<Resolution>(count);
|
||||||
Memory::CopyArray(*outResolutions, resolutions.data(), count);
|
std::copy_n(resolutions.begin(), count, *outResolutions);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#pragma warning(disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
|
#pragma warning(disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include "core/FileStream.hpp"
|
#include "core/FileStream.hpp"
|
||||||
#include "core/Guard.hpp"
|
#include "core/Guard.hpp"
|
||||||
@@ -107,7 +108,7 @@ namespace Imaging
|
|||||||
Guard::Assert(rowBytes == pngWidth, GUARD_LINE);
|
Guard::Assert(rowBytes == pngWidth, GUARD_LINE);
|
||||||
for (png_uint_32 i = 0; i < pngHeight; i++)
|
for (png_uint_32 i = 0; i < pngHeight; i++)
|
||||||
{
|
{
|
||||||
Memory::Copy(dst, rowPointers[i], rowBytes);
|
std::copy_n(rowPointers[i], rowBytes, dst);
|
||||||
dst += rowBytes;
|
dst += rowBytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +118,7 @@ namespace Imaging
|
|||||||
Guard::Assert(rowBytes == pngWidth * 4, GUARD_LINE);
|
Guard::Assert(rowBytes == pngWidth * 4, GUARD_LINE);
|
||||||
for (png_uint_32 i = 0; i < pngHeight; i++)
|
for (png_uint_32 i = 0; i < pngHeight; i++)
|
||||||
{
|
{
|
||||||
Memory::Copy(dst, rowPointers[i], rowBytes);
|
std::copy_n(rowPointers[i], rowBytes, dst);
|
||||||
dst += rowBytes;
|
dst += rowBytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
@@ -47,7 +48,7 @@ GameActionResult::GameActionResult(GA_ERROR error, rct_string_id title, rct_stri
|
|||||||
Error = error;
|
Error = error;
|
||||||
ErrorTitle = title;
|
ErrorTitle = title;
|
||||||
ErrorMessage = message;
|
ErrorMessage = message;
|
||||||
Memory::CopyArray(ErrorMessageArgs, args, Util::CountOf(ErrorMessageArgs));
|
std::copy_n(args, ErrorMessageArgs.size(), ErrorMessageArgs.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace GameActions
|
namespace GameActions
|
||||||
@@ -129,7 +130,7 @@ namespace GameActions
|
|||||||
{
|
{
|
||||||
result->Error = GA_ERROR::INSUFFICIENT_FUNDS;
|
result->Error = GA_ERROR::INSUFFICIENT_FUNDS;
|
||||||
result->ErrorMessage = STR_NOT_ENOUGH_CASH_REQUIRES;
|
result->ErrorMessage = STR_NOT_ENOUGH_CASH_REQUIRES;
|
||||||
set_format_arg_on(result->ErrorMessageArgs, 0, uint32, result->Cost);
|
set_format_arg_on(result->ErrorMessageArgs.data(), 0, uint32, result->Cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -214,7 +215,7 @@ namespace GameActions
|
|||||||
if (result->Error != GA_ERROR::OK && !(flags & GAME_COMMAND_FLAG_GHOST))
|
if (result->Error != GA_ERROR::OK && !(flags & GAME_COMMAND_FLAG_GHOST))
|
||||||
{
|
{
|
||||||
// Show the error box
|
// Show the error box
|
||||||
Memory::Copy(gCommonFormatArgs, result->ErrorMessageArgs, sizeof(result->ErrorMessageArgs));
|
std::copy(result->ErrorMessageArgs.begin(), result->ErrorMessageArgs.end(), gCommonFormatArgs);
|
||||||
context_show_error(result->ErrorTitle, result->ErrorMessage);
|
context_show_error(result->ErrorTitle, result->ErrorMessage);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -71,13 +72,13 @@ class GameActionResult
|
|||||||
public:
|
public:
|
||||||
typedef std::unique_ptr<GameActionResult> Ptr;
|
typedef std::unique_ptr<GameActionResult> Ptr;
|
||||||
|
|
||||||
GA_ERROR Error = GA_ERROR::OK;
|
GA_ERROR Error = GA_ERROR::OK;
|
||||||
rct_string_id ErrorTitle = STR_NONE;
|
rct_string_id ErrorTitle = STR_NONE;
|
||||||
rct_string_id ErrorMessage = STR_NONE;
|
rct_string_id ErrorMessage = STR_NONE;
|
||||||
uint8 ErrorMessageArgs[12] = { 0 };
|
std::array<uint8, 12> ErrorMessageArgs;
|
||||||
LocationXYZ32 Position = { 0 };
|
LocationXYZ32 Position = { 0 };
|
||||||
money32 Cost = 0;
|
money32 Cost = 0;
|
||||||
uint16 ExpenditureType = 0;
|
uint16 ExpenditureType = 0;
|
||||||
|
|
||||||
GameActionResult();
|
GameActionResult();
|
||||||
GameActionResult(GA_ERROR error, rct_string_id message);
|
GameActionResult(GA_ERROR error, rct_string_id message);
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public:
|
|||||||
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
|
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
|
||||||
Ride *ride = get_ride(_rideIndex);
|
Ride *ride = get_ride(_rideIndex);
|
||||||
res->ErrorTitle = _StatusErrorTitles[_status];
|
res->ErrorTitle = _StatusErrorTitles[_status];
|
||||||
set_format_arg_on(res->ErrorMessageArgs, 6, rct_string_id, ride->name);
|
set_format_arg_on(res->ErrorMessageArgs.data(), 6, rct_string_id, ride->name);
|
||||||
set_format_arg_on(res->ErrorMessageArgs, 8, uint32, ride->name_arguments);
|
set_format_arg_on(res->ErrorMessageArgs.data(), 8, uint32, ride->name_arguments);
|
||||||
|
|
||||||
if (_rideIndex >= MAX_RIDES || _rideIndex < 0)
|
if (_rideIndex >= MAX_RIDES || _rideIndex < 0)
|
||||||
{
|
{
|
||||||
@@ -104,8 +104,8 @@ public:
|
|||||||
|
|
||||||
Ride *ride = get_ride(_rideIndex);
|
Ride *ride = get_ride(_rideIndex);
|
||||||
res->ErrorTitle = _StatusErrorTitles[_status];
|
res->ErrorTitle = _StatusErrorTitles[_status];
|
||||||
set_format_arg_on(res->ErrorMessageArgs, 6, rct_string_id, ride->name);
|
set_format_arg_on(res->ErrorMessageArgs.data(), 6, rct_string_id, ride->name);
|
||||||
set_format_arg_on(res->ErrorMessageArgs, 8,uint32, ride->name_arguments);
|
set_format_arg_on(res->ErrorMessageArgs.data(), 8,uint32, ride->name_arguments);
|
||||||
|
|
||||||
if (ride->type == RIDE_TYPE_NULL)
|
if (ride->type == RIDE_TYPE_NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ utf8 * IStream::ReadString()
|
|||||||
result.push_back(0);
|
result.push_back(0);
|
||||||
|
|
||||||
utf8 * resultString = Memory::AllocateArray<utf8>(result.size());
|
utf8 * resultString = Memory::AllocateArray<utf8>(result.size());
|
||||||
Memory::CopyArray(resultString, result.data(), result.size());
|
std::copy(result.begin(), result.end(), resultString);
|
||||||
return resultString;
|
return resultString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,45 +88,18 @@ namespace Memory
|
|||||||
free((void*)ptr);
|
free((void*)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static T * Copy(T * dst, const T * src, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0) return (T*)dst;
|
|
||||||
#ifdef DEBUG
|
|
||||||
uintptr_t srcBegin = (uintptr_t)src;
|
|
||||||
uintptr_t srcEnd = srcBegin + size;
|
|
||||||
uintptr_t dstBegin = (uintptr_t)dst;
|
|
||||||
uintptr_t dstEnd = dstBegin + size;
|
|
||||||
Guard::Assert(srcEnd <= dstBegin || srcBegin >= dstEnd, "Source overlaps destination, try using Memory::Move.");
|
|
||||||
#endif
|
|
||||||
return (T*)memcpy((void*)dst, (const void*)src, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T * Duplicate(const T * src, size_t size)
|
static T * Duplicate(const T * src, size_t size)
|
||||||
{
|
{
|
||||||
T *result = Allocate<T>(size);
|
T *result = Allocate<T>(size);
|
||||||
return Copy(result, src, size);
|
return (T *)memcpy(result, src, size);
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static T * CopyArray(T * dst, const T * src, size_t count)
|
|
||||||
{
|
|
||||||
// Use a loop so that copy constructors are called
|
|
||||||
// compiler should optimise to memcpy if possible
|
|
||||||
T * result = dst;
|
|
||||||
for (; count > 0; count--)
|
|
||||||
{
|
|
||||||
*dst++ = *src++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T * DuplicateArray(const T * src, size_t count)
|
static T * DuplicateArray(const T * src, size_t count)
|
||||||
{
|
{
|
||||||
T * result = AllocateArray<T>(count);
|
T * result = AllocateArray<T>(count);
|
||||||
return CopyArray(result, src, count);
|
return (T *)memcpy(result, src, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include "Math.hpp"
|
#include "Math.hpp"
|
||||||
#include "Memory.hpp"
|
#include "Memory.hpp"
|
||||||
#include "MemoryStream.h"
|
#include "MemoryStream.h"
|
||||||
@@ -135,7 +136,7 @@ void MemoryStream::Read(void * buffer, uint64 length)
|
|||||||
throw IOException("Attempted to read past end of stream.");
|
throw IOException("Attempted to read past end of stream.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Copy(buffer, _position, (size_t)length);
|
std::copy_n((const uint8 *)_position, length, (uint8 *)buffer);
|
||||||
_position = (void*)((uintptr_t)_position + length);
|
_position = (void*)((uintptr_t)_position + length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ void MemoryStream::Write(const void * buffer, uint64 length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Copy(_position, buffer, (size_t)length);
|
std::copy_n((const uint8 *)buffer, length, (uint8 *)_position);
|
||||||
_position = (void*)((uintptr_t)_position + length);
|
_position = (void*)((uintptr_t)_position + length);
|
||||||
_dataSize = Math::Max<size_t>(_dataSize, (size_t)nextPosition);
|
_dataSize = Math::Max<size_t>(_dataSize, (size_t)nextPosition);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -74,7 +75,7 @@ namespace Path
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t copyLength = Math::Min(lastPathSepIndex, static_cast<ptrdiff_t>(bufferSize - 1));
|
size_t copyLength = Math::Min(lastPathSepIndex, static_cast<ptrdiff_t>(bufferSize - 1));
|
||||||
Memory::Copy(buffer, path, copyLength);
|
std::copy_n(path, copyLength, buffer);
|
||||||
buffer[copyLength] = '\0';
|
buffer[copyLength] = '\0';
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -148,7 +149,7 @@ namespace Path
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t truncatedLength = Math::Min<size_t>(bufferSize - 1, lastDot - path);
|
size_t truncatedLength = Math::Min<size_t>(bufferSize - 1, lastDot - path);
|
||||||
Memory::Copy(buffer, path, truncatedLength);
|
std::copy_n(path, truncatedLength, buffer);
|
||||||
buffer[truncatedLength] = '\0';
|
buffer[truncatedLength] = '\0';
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cwctype>
|
#include <cwctype>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -376,7 +377,7 @@ namespace String
|
|||||||
}
|
}
|
||||||
|
|
||||||
utf8 * result = Memory::Allocate<utf8>(size + 1);
|
utf8 * result = Memory::Allocate<utf8>(size + 1);
|
||||||
Memory::Copy(result, buffer + index, size);
|
std::copy_n(buffer + index, size, result);
|
||||||
result[size] = '\0';
|
result[size] = '\0';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#include "Math.hpp"
|
#include "Math.hpp"
|
||||||
@@ -75,7 +76,7 @@ public:
|
|||||||
void Append(const utf8 * text, size_t textLength)
|
void Append(const utf8 * text, size_t textLength)
|
||||||
{
|
{
|
||||||
EnsureCapacity(_length + textLength + 1);
|
EnsureCapacity(_length + textLength + 1);
|
||||||
Memory::Copy(_buffer + _length, text, textLength);
|
std::copy_n(text, textLength, _buffer + _length);
|
||||||
_length += textLength;
|
_length += textLength;
|
||||||
_buffer[_length] = 0;
|
_buffer[_length] = 0;
|
||||||
}
|
}
|
||||||
@@ -133,7 +134,7 @@ public:
|
|||||||
{
|
{
|
||||||
// If buffer is null, length should be 0 which will create a new one byte memory block containing a null terminator
|
// If buffer is null, length should be 0 which will create a new one byte memory block containing a null terminator
|
||||||
utf8 * result = Memory::AllocateArray<utf8>(_length + 1);
|
utf8 * result = Memory::AllocateArray<utf8>(_length + 1);
|
||||||
Memory::CopyArray(result, _buffer, _length);
|
std::copy_n(_buffer, _length, result);
|
||||||
result[_length] = 0;
|
result[_length] = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ void X8DrawingEngine::ConfigureBits(uint32 width, uint32 height, uint32 pitch)
|
|||||||
{
|
{
|
||||||
if (_pitch == pitch)
|
if (_pitch == pitch)
|
||||||
{
|
{
|
||||||
Memory::Copy(newBits, _bits, Math::Min(_bitsSize, newBitsSize));
|
std::copy_n(_bits, std::min(_bitsSize, newBitsSize), newBits);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -331,7 +331,7 @@ void X8DrawingEngine::ConfigureBits(uint32 width, uint32 height, uint32 pitch)
|
|||||||
uint32 minHeight = Math::Min(_height, height);
|
uint32 minHeight = Math::Min(_height, height);
|
||||||
for (uint32 y = 0; y < minHeight; y++)
|
for (uint32 y = 0; y < minHeight; y++)
|
||||||
{
|
{
|
||||||
Memory::Copy(dst, src, minWidth);
|
std::copy_n(src, minWidth, dst);
|
||||||
if (pitch - minWidth > 0)
|
if (pitch - minWidth > 0)
|
||||||
{
|
{
|
||||||
std::fill_n(dst + minWidth, pitch - minWidth, 0);
|
std::fill_n(dst + minWidth, pitch - minWidth, 0);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -407,7 +408,7 @@ private:
|
|||||||
|
|
||||||
_objectOverrides.push_back(ObjectOverride());
|
_objectOverrides.push_back(ObjectOverride());
|
||||||
_currentObjectOverride = &_objectOverrides[_objectOverrides.size() - 1];
|
_currentObjectOverride = &_objectOverrides[_objectOverrides.size() - 1];
|
||||||
Memory::Copy(_currentObjectOverride->name, _currentGroup.c_str(), 8);
|
std::copy_n(_currentGroup.c_str(), 8, _currentObjectOverride->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Object::Object(const rct_object_entry &entry)
|
|||||||
_objectEntry = entry;
|
_objectEntry = entry;
|
||||||
|
|
||||||
char name[DAT_NAME_LENGTH + 1] = { 0 };
|
char name[DAT_NAME_LENGTH + 1] = { 0 };
|
||||||
Memory::Copy(name, entry.name, DAT_NAME_LENGTH);
|
std::copy_n(entry.name, DAT_NAME_LENGTH, name);
|
||||||
_identifier = String::Duplicate(name);
|
_identifier = String::Duplicate(name);
|
||||||
|
|
||||||
if (IsRCT1Object())
|
if (IsRCT1Object())
|
||||||
@@ -90,7 +90,7 @@ rct_object_entry Object::CreateHeader(const char name[DAT_NAME_LENGTH + 1], uint
|
|||||||
{
|
{
|
||||||
rct_object_entry header = { 0 };
|
rct_object_entry header = { 0 };
|
||||||
header.flags = flags;
|
header.flags = flags;
|
||||||
Memory::Copy(header.name, name, DAT_NAME_LENGTH);
|
std::copy_n(name, DAT_NAME_LENGTH, header.name);
|
||||||
header.checksum = checksum;
|
header.checksum = checksum;
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -592,14 +592,14 @@ private:
|
|||||||
static void ReportMissingObject(const rct_object_entry * entry)
|
static void ReportMissingObject(const rct_object_entry * entry)
|
||||||
{
|
{
|
||||||
utf8 objName[DAT_NAME_LENGTH + 1] = { 0 };
|
utf8 objName[DAT_NAME_LENGTH + 1] = { 0 };
|
||||||
Memory::Copy(objName, entry->name, DAT_NAME_LENGTH);
|
std::copy_n(entry->name, DAT_NAME_LENGTH, objName);
|
||||||
Console::Error::WriteLine("[%s] Object not found.", objName);
|
Console::Error::WriteLine("[%s] Object not found.", objName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportObjectLoadProblem(const rct_object_entry * entry)
|
void ReportObjectLoadProblem(const rct_object_entry * entry)
|
||||||
{
|
{
|
||||||
utf8 objName[DAT_NAME_LENGTH + 1] = { 0 };
|
utf8 objName[DAT_NAME_LENGTH + 1] = { 0 };
|
||||||
Memory::Copy(objName, entry->name, DAT_NAME_LENGTH);
|
std::copy_n(entry->name, DAT_NAME_LENGTH, objName);
|
||||||
Console::Error::WriteLine("[%s] Object could not be loaded.", objName);
|
Console::Error::WriteLine("[%s] Object could not be loaded.", objName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public:
|
|||||||
rct_object_entry entry = { 0 };
|
rct_object_entry entry = { 0 };
|
||||||
utf8 entryName[9] = { ' ' };
|
utf8 entryName[9] = { ' ' };
|
||||||
String::Set(entryName, sizeof(entryName), name);
|
String::Set(entryName, sizeof(entryName), name);
|
||||||
Memory::Copy<void>(entry.name, entryName, 8);
|
std::copy_n(entryName, 8, entry.name);
|
||||||
|
|
||||||
auto kvp = _itemMap.find(entry);
|
auto kvp = _itemMap.find(entry);
|
||||||
if (kvp != _itemMap.end())
|
if (kvp != _itemMap.end())
|
||||||
@@ -464,10 +464,10 @@ private:
|
|||||||
|
|
||||||
// Create new data blob with appended bytes
|
// Create new data blob with appended bytes
|
||||||
size_t newDataSize = dataSize + extraBytesCount;
|
size_t newDataSize = dataSize + extraBytesCount;
|
||||||
void * newData = Memory::Allocate<void>(newDataSize);
|
uint8 * newData = Memory::Allocate<uint8>(newDataSize);
|
||||||
void * newDataSaltOffset = (void *)((uintptr_t)newData + dataSize);
|
uint8 * newDataSaltOffset = newData + dataSize;
|
||||||
Memory::Copy(newData, data, dataSize);
|
std::copy_n((const uint8 *)data, dataSize, newData);
|
||||||
Memory::Copy(newDataSaltOffset, extraBytes, extraBytesCount);
|
std::copy_n((const uint8 *)extraBytes, extraBytesCount, newDataSaltOffset);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public:
|
|||||||
|
|
||||||
if (decodedSize == sizeof(rct1_s4))
|
if (decodedSize == sizeof(rct1_s4))
|
||||||
{
|
{
|
||||||
Memory::Copy<void>(&_s4, decodedData.get(), sizeof(rct1_s4));
|
std::memcpy(&_s4, decodedData.get(), sizeof(rct1_s4));
|
||||||
if (_s4Path)
|
if (_s4Path)
|
||||||
{
|
{
|
||||||
Memory::Free(_s4Path);
|
Memory::Free(_s4Path);
|
||||||
@@ -1353,7 +1353,7 @@ private:
|
|||||||
std::fill(std::begin(gStaffModes), std::end(gStaffModes), 0);
|
std::fill(std::begin(gStaffModes), std::end(gStaffModes), 0);
|
||||||
std::fill(std::begin(gStaffPatrolAreas), std::end(gStaffPatrolAreas), 0);
|
std::fill(std::begin(gStaffPatrolAreas), std::end(gStaffPatrolAreas), 0);
|
||||||
|
|
||||||
Memory::Copy(gStaffModes, _s4.staff_modes, sizeof(_s4.staff_modes));
|
std::copy(std::begin(_s4.staff_modes), std::end(_s4.staff_modes), gStaffModes);
|
||||||
|
|
||||||
FOR_ALL_STAFF(i, peep)
|
FOR_ALL_STAFF(i, peep)
|
||||||
{
|
{
|
||||||
@@ -1856,7 +1856,7 @@ private:
|
|||||||
{
|
{
|
||||||
rct_object_entry entry;
|
rct_object_entry entry;
|
||||||
entry.flags = 0x00008000 + objectType;
|
entry.flags = 0x00008000 + objectType;
|
||||||
Memory::Copy(entry.name, objectName, 8);
|
std::copy_n(objectName, 8, entry.name);
|
||||||
entry.checksum = 0;
|
entry.checksum = 0;
|
||||||
|
|
||||||
Object * object = objectManager->LoadObject(&entry);
|
Object * object = objectManager->LoadObject(&entry);
|
||||||
@@ -1903,7 +1903,7 @@ private:
|
|||||||
{
|
{
|
||||||
rct_object_entry entry;
|
rct_object_entry entry;
|
||||||
entry.flags = 0x00008000 + objectType;
|
entry.flags = 0x00008000 + objectType;
|
||||||
Memory::Copy(entry.name, objectName, 8);
|
std::copy_n(objectName, 8, entry.name);
|
||||||
entry.checksum = 0;
|
entry.checksum = 0;
|
||||||
|
|
||||||
const ObjectRepositoryItem * ori = objectRepository->FindObject(&entry);
|
const ObjectRepositoryItem * ori = objectRepository->FindObject(&entry);
|
||||||
@@ -1927,7 +1927,10 @@ private:
|
|||||||
|
|
||||||
void ImportTileElements()
|
void ImportTileElements()
|
||||||
{
|
{
|
||||||
Memory::Copy(gTileElements, _s4.tile_elements, RCT1_MAX_TILE_ELEMENTS * sizeof(rct_tile_element));
|
std::copy(
|
||||||
|
std::begin(_s4.tile_elements),
|
||||||
|
std::end(_s4.tile_elements),
|
||||||
|
gTileElements);
|
||||||
ClearExtraTileEntries();
|
ClearExtraTileEntries();
|
||||||
FixSceneryColours();
|
FixSceneryColours();
|
||||||
FixTileElementZ();
|
FixTileElementZ();
|
||||||
@@ -2172,7 +2175,7 @@ private:
|
|||||||
dst->Ticks = src->Ticks;
|
dst->Ticks = src->Ticks;
|
||||||
dst->MonthYear = src->MonthYear;
|
dst->MonthYear = src->MonthYear;
|
||||||
dst->Day = src->Day;
|
dst->Day = src->Day;
|
||||||
Memory::Copy(dst->Text, src->Text, sizeof(src->Text));
|
std::copy(std::begin(src->Text), std::end(src->Text), dst->Text);
|
||||||
|
|
||||||
if (dst->Type == NEWS_ITEM_RESEARCH)
|
if (dst->Type == NEWS_ITEM_RESEARCH)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -107,19 +107,19 @@ std::shared_ptr<SawyerChunk> SawyerChunkReader::ReadChunk()
|
|||||||
void SawyerChunkReader::ReadChunk(void * dst, size_t length)
|
void SawyerChunkReader::ReadChunk(void * dst, size_t length)
|
||||||
{
|
{
|
||||||
auto chunk = ReadChunk();
|
auto chunk = ReadChunk();
|
||||||
const void * chunkData = chunk->GetData();
|
auto chunkData = (const uint8 *)chunk->GetData();
|
||||||
size_t chunkLength = chunk->GetLength();
|
auto chunkLength = chunk->GetLength();
|
||||||
if (chunkLength > length)
|
if (chunkLength > length)
|
||||||
{
|
{
|
||||||
Memory::Copy(dst, chunkData, length);
|
std::copy_n(chunkData, length, (uint8 *)dst);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Copy(dst, chunkData, chunkLength);
|
std::copy_n(chunkData, length, (uint8 *)dst);
|
||||||
size_t remainingLength = length - chunkLength;
|
auto remainingLength = length - chunkLength;
|
||||||
if (remainingLength > 0)
|
if (remainingLength > 0)
|
||||||
{
|
{
|
||||||
uint8 * offset = (uint8 *)((uintptr_t)dst + chunkLength);
|
auto offset = (uint8 *)dst + chunkLength;
|
||||||
std::fill_n(offset, remainingLength, 0);
|
std::fill_n(offset, remainingLength, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ size_t SawyerChunkReader::DecodeChunk(void * dst, size_t dstCapacity, const void
|
|||||||
{
|
{
|
||||||
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
|
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
|
||||||
}
|
}
|
||||||
Memory::Copy(dst, src, header.length);
|
std::copy_n((const uint8 *)src, header.length, (uint8 *)dst);
|
||||||
resultLength = header.length;
|
resultLength = header.length;
|
||||||
break;
|
break;
|
||||||
case CHUNK_ENCODING_RLE:
|
case CHUNK_ENCODING_RLE:
|
||||||
@@ -197,7 +197,7 @@ size_t SawyerChunkReader::DecodeChunkRLE(void * dst, size_t dstCapacity, const v
|
|||||||
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
|
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Copy(dst8, src8 + i + 1, rleCodeByte + 1);
|
std::copy_n(src8 + i + 1, rleCodeByte + 1, dst8);
|
||||||
dst8 += rleCodeByte + 1;
|
dst8 += rleCodeByte + 1;
|
||||||
i += rleCodeByte + 1;
|
i += rleCodeByte + 1;
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ size_t SawyerChunkReader::DecodeChunkRepeat(void * dst, size_t dstCapacity, cons
|
|||||||
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
|
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Copy(dst8, copySrc, count);
|
std::copy_n(copySrc, count, dst8);
|
||||||
dst8 += count;
|
dst8 += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
@@ -306,10 +308,10 @@ static money32 BannerSetName(uint8 bannerIndex,
|
|||||||
return MONEY32_UNDEFINED;
|
return MONEY32_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nameChunkOffset = Math::Min<size_t>(indexToOffset[nameChunkIndex], Util::CountOf(newName) - 12);
|
size_t nameChunkOffset = std::min<size_t>(indexToOffset[nameChunkIndex], Util::CountOf(newName) - 12);
|
||||||
Memory::Copy<uint32>((uint32*)(&newName[0 + nameChunkOffset]), &nameChunk1, sizeof(uint32));
|
std::memcpy(&newName[0 + nameChunkOffset], &nameChunk1, sizeof(uint32));
|
||||||
Memory::Copy<uint32>((uint32*)(&newName[4 + nameChunkOffset]), &nameChunk2, sizeof(uint32));
|
std::memcpy(&newName[4 + nameChunkOffset], &nameChunk2, sizeof(uint32));
|
||||||
Memory::Copy<uint32>((uint32*)(&newName[8 + nameChunkOffset]), &nameChunk3, sizeof(uint32));
|
std::memcpy(&newName[8 + nameChunkOffset], &nameChunk3, sizeof(uint32));
|
||||||
|
|
||||||
if (nameChunkIndex != 0)
|
if (nameChunkIndex != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user