mirror of https://github.com/OpenRCT2/OpenRCT2.git
Replace Memory::Set with std::fill or similar
This commit is contained in:
parent
522e113929
commit
7851446a6f
|
@ -16,6 +16,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include "../core/Memory.hpp"
|
||||
#include "../core/MemoryStream.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
|
@ -262,7 +263,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Memory::Set(ride->num_customers, 0, sizeof(ride->num_customers));
|
||||
std::fill(
|
||||
std::begin(ride->num_customers),
|
||||
std::end(ride->num_customers),
|
||||
0);
|
||||
ride->value = 0xFFFF;
|
||||
ride->satisfaction = 255;
|
||||
ride->satisfaction_time_out = 0;
|
||||
|
|
|
@ -120,12 +120,6 @@ namespace Memory
|
|||
return Copy(result, src, size);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static T * Set(T * dst, uint8 value, size_t size)
|
||||
{
|
||||
return (T*)memset((void*)dst, (sint32)value, size);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static T * CopyArray(T * dst, const T * src, size_t count)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include "../config/Config.h"
|
||||
#include "../Context.h"
|
||||
#include "../ui/UiContext.h"
|
||||
|
@ -313,7 +314,7 @@ void X8DrawingEngine::ConfigureBits(uint32 width, uint32 height, uint32 pitch)
|
|||
uint8 * newBits = new uint8[newBitsSize];
|
||||
if (_bits == nullptr)
|
||||
{
|
||||
Memory::Set(newBits, 0, newBitsSize);
|
||||
std::fill_n(newBits, newBitsSize, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -333,7 +334,7 @@ void X8DrawingEngine::ConfigureBits(uint32 width, uint32 height, uint32 pitch)
|
|||
Memory::Copy(dst, src, minWidth);
|
||||
if (pitch - minWidth > 0)
|
||||
{
|
||||
Memory::Set(dst + minWidth, 0, pitch - minWidth);
|
||||
std::fill_n(dst + minWidth, pitch - minWidth, 0);
|
||||
}
|
||||
src += _pitch;
|
||||
dst += pitch;
|
||||
|
@ -490,7 +491,7 @@ void X8DrawingContext::Clear(uint8 paletteIndex)
|
|||
|
||||
for (sint32 y = 0; y < h; y++)
|
||||
{
|
||||
Memory::Set(ptr, paletteIndex, w);
|
||||
std::fill_n(ptr, w, paletteIndex);
|
||||
ptr += w + dpi->pitch;
|
||||
}
|
||||
}
|
||||
|
@ -652,7 +653,7 @@ void X8DrawingContext::FillRect(uint32 colour, sint32 left, sint32 top, sint32 r
|
|||
uint8 * dst = startY * (dpi->width + dpi->pitch) + startX + dpi->bits;
|
||||
for (sint32 i = 0; i < height; i++)
|
||||
{
|
||||
Memory::Set(dst, colour & 0xFF, width);
|
||||
std::fill_n(dst, width, colour & 0xFF);
|
||||
dst += dpi->width + dpi->pitch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include "../config/Config.h"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/Util.hpp"
|
||||
|
@ -766,32 +767,50 @@ void set_all_scenery_groups_not_invented()
|
|||
|
||||
void set_all_scenery_items_invented()
|
||||
{
|
||||
Memory::Set(_researchedSceneryItems, true, sizeof(_researchedSceneryItems));
|
||||
std::fill(
|
||||
std::begin(_researchedSceneryItems),
|
||||
std::end(_researchedSceneryItems),
|
||||
true);
|
||||
}
|
||||
|
||||
void set_all_scenery_items_not_invented()
|
||||
{
|
||||
Memory::Set(_researchedSceneryItems, false, sizeof(_researchedSceneryItems));
|
||||
std::fill(
|
||||
std::begin(_researchedSceneryItems),
|
||||
std::end(_researchedSceneryItems),
|
||||
false);
|
||||
}
|
||||
|
||||
void set_every_ride_type_invented()
|
||||
{
|
||||
Memory::Set(_researchedRideTypes, true, sizeof(_researchedRideTypes));
|
||||
std::fill(
|
||||
std::begin(_researchedRideTypes),
|
||||
std::end(_researchedRideTypes),
|
||||
true);
|
||||
}
|
||||
|
||||
void set_every_ride_type_not_invented()
|
||||
{
|
||||
Memory::Set(_researchedRideTypes, false, sizeof(_researchedRideTypes));
|
||||
std::fill(
|
||||
std::begin(_researchedRideTypes),
|
||||
std::end(_researchedRideTypes),
|
||||
false);
|
||||
}
|
||||
|
||||
void set_every_ride_entry_invented()
|
||||
{
|
||||
Memory::Set(_researchedRideEntries, true, sizeof(_researchedRideEntries));
|
||||
std::fill(
|
||||
std::begin(_researchedRideEntries),
|
||||
std::end(_researchedRideEntries),
|
||||
true);
|
||||
}
|
||||
|
||||
void set_every_ride_entry_not_invented()
|
||||
{
|
||||
Memory::Set(_researchedRideEntries, false, sizeof(_researchedRideEntries));
|
||||
std::fill(
|
||||
std::begin(_researchedRideEntries),
|
||||
std::end(_researchedRideEntries),
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
|
@ -82,8 +83,8 @@ void ImageTable::Read(IReadObjectContext * context, IStream * stream)
|
|||
size_t unreadBytes = _dataSize - readBytes;
|
||||
if (unreadBytes > 0)
|
||||
{
|
||||
void * ptr = (void*)(((uintptr_t)_data) + readBytes);
|
||||
Memory::Set(ptr, 0, unreadBytes);
|
||||
uint8 * ptr = (uint8*)(((uintptr_t)_data) + readBytes);
|
||||
std::fill_n(ptr, unreadBytes, 0);
|
||||
|
||||
context->LogWarning(OBJECT_ERROR_BAD_IMAGE_TABLE, "Image table size shorter than expected.");
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
|
@ -388,7 +389,7 @@ private:
|
|||
void * * legacyChunk = &object_entry_groups[objectType].chunks[entryIndex];
|
||||
if (loadedObject == nullptr)
|
||||
{
|
||||
Memory::Set(legacyEntry, 0x00, sizeof(rct_object_entry_extended));
|
||||
*legacyEntry = { 0 };
|
||||
*legacyChunk = nullptr;
|
||||
}
|
||||
else
|
||||
|
@ -474,19 +475,19 @@ private:
|
|||
invalidEntries.reserve(OBJECT_ENTRY_COUNT);
|
||||
for (sint32 i = 0; i < OBJECT_ENTRY_COUNT; i++)
|
||||
{
|
||||
const rct_object_entry * entry = &entries[i];
|
||||
auto entry = entries[i];
|
||||
const ObjectRepositoryItem * ori = nullptr;
|
||||
if (object_entry_is_empty(entry))
|
||||
if (object_entry_is_empty(&entry))
|
||||
{
|
||||
Memory::Set(entry, 0, sizeof(rct_object_entry));
|
||||
entry = { 0 };
|
||||
continue;
|
||||
}
|
||||
|
||||
ori = _objectRepository->FindObject(entry);
|
||||
ori = _objectRepository->FindObject(&entry);
|
||||
if (ori == nullptr)
|
||||
{
|
||||
invalidEntries.push_back(*entry);
|
||||
ReportMissingObject(entry);
|
||||
invalidEntries.push_back(entry);
|
||||
ReportMissingObject(&entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -497,8 +498,8 @@ private:
|
|||
loadedObject = _objectRepository->LoadObject(ori);
|
||||
if (loadedObject == nullptr)
|
||||
{
|
||||
invalidEntries.push_back(*entry);
|
||||
ReportObjectLoadProblem(entry);
|
||||
invalidEntries.push_back(entry);
|
||||
ReportObjectLoadProblem(&entry);
|
||||
}
|
||||
delete loadedObject;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "../core/Collections.hpp"
|
||||
|
@ -241,7 +242,7 @@ public:
|
|||
|
||||
bool GetDetails(scenario_index_entry * dst) override
|
||||
{
|
||||
Memory::Set(dst, 0, sizeof(scenario_index_entry));
|
||||
*dst = { 0 };
|
||||
|
||||
source_desc desc;
|
||||
// If no entry is found, this is a custom scenario.
|
||||
|
@ -353,14 +354,14 @@ private:
|
|||
|
||||
void InitialiseEntryMaps()
|
||||
{
|
||||
Memory::Set(_rideTypeToRideEntryMap, 255, sizeof(_rideTypeToRideEntryMap));
|
||||
Memory::Set(_vehicleTypeToRideEntryMap, 255, sizeof(_vehicleTypeToRideEntryMap));
|
||||
Memory::Set(_smallSceneryTypeToEntryMap, 255, sizeof(_smallSceneryTypeToEntryMap));
|
||||
Memory::Set(_largeSceneryTypeToEntryMap, 255, sizeof(_largeSceneryTypeToEntryMap));
|
||||
Memory::Set(_wallTypeToEntryMap, 255, sizeof(_wallTypeToEntryMap));
|
||||
Memory::Set(_pathTypeToEntryMap, 255, sizeof(_pathTypeToEntryMap));
|
||||
Memory::Set(_pathAdditionTypeToEntryMap, 255, sizeof(_pathAdditionTypeToEntryMap));
|
||||
Memory::Set(_sceneryThemeTypeToEntryMap, 255, sizeof(_sceneryThemeTypeToEntryMap));
|
||||
std::fill(std::begin(_rideTypeToRideEntryMap), std::end(_rideTypeToRideEntryMap), 255);
|
||||
std::fill(std::begin(_vehicleTypeToRideEntryMap), std::end(_vehicleTypeToRideEntryMap), 255);
|
||||
std::fill(std::begin(_smallSceneryTypeToEntryMap), std::end(_smallSceneryTypeToEntryMap), 255);
|
||||
std::fill(std::begin(_largeSceneryTypeToEntryMap), std::end(_largeSceneryTypeToEntryMap), 255);
|
||||
std::fill(std::begin(_wallTypeToEntryMap), std::end(_wallTypeToEntryMap), 255);
|
||||
std::fill(std::begin(_pathTypeToEntryMap), std::end(_pathTypeToEntryMap), 255);
|
||||
std::fill(std::begin(_pathAdditionTypeToEntryMap), std::end(_pathAdditionTypeToEntryMap), 255);
|
||||
std::fill(std::begin(_sceneryThemeTypeToEntryMap), std::end(_sceneryThemeTypeToEntryMap), 255);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1349,8 +1350,8 @@ private:
|
|||
}
|
||||
|
||||
// The RCT2/OpenRCT2 structures are bigger than in RCT1, so set them to zero
|
||||
Memory::Set(gStaffModes, 0, sizeof(gStaffModes));
|
||||
Memory::Set(gStaffPatrolAreas, 0, sizeof(gStaffPatrolAreas));
|
||||
std::fill(std::begin(gStaffModes), std::end(gStaffModes), 0);
|
||||
std::fill(std::begin(gStaffPatrolAreas), std::end(gStaffPatrolAreas), 0);
|
||||
|
||||
Memory::Copy(gStaffModes, _s4.staff_modes, sizeof(_s4.staff_modes));
|
||||
|
||||
|
@ -1949,8 +1950,8 @@ private:
|
|||
const rct1_research_item * researchList = GetResearchList(&researchListCount);
|
||||
|
||||
// Initialise the "seen" tables
|
||||
Memory::Set(_researchRideEntryUsed, 0, sizeof(_researchRideEntryUsed));
|
||||
Memory::Set(_researchRideTypeUsed, 0, sizeof(_researchRideTypeUsed));
|
||||
std::fill(std::begin(_researchRideEntryUsed), std::end(_researchRideEntryUsed), 0);
|
||||
std::fill(std::begin(_researchRideTypeUsed), std::end(_researchRideTypeUsed), 0);
|
||||
|
||||
// The first six scenery groups are always available
|
||||
for (uint8 i = 0; i < 6; i++)
|
||||
|
@ -2341,7 +2342,7 @@ private:
|
|||
void ClearExtraTileEntries()
|
||||
{
|
||||
// Reset the map tile pointers
|
||||
Memory::Set(gTileElementTilePointers, 0, sizeof(rct_tile_element*) * MAX_TILE_TILE_ELEMENT_POINTERS);
|
||||
std::fill(std::begin(gTileElementTilePointers), std::end(gTileElementTilePointers), nullptr);
|
||||
|
||||
// Get the first free map element
|
||||
rct_tile_element * nextFreeTileElement = gTileElements;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Math.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
|
@ -118,8 +119,8 @@ void SawyerChunkReader::ReadChunk(void * dst, size_t length)
|
|||
size_t remainingLength = length - chunkLength;
|
||||
if (remainingLength > 0)
|
||||
{
|
||||
void * offset = (void *)((uintptr_t)dst + chunkLength);
|
||||
Memory::Set(offset, 0, remainingLength);
|
||||
uint8 * offset = (uint8 *)((uintptr_t)dst + chunkLength);
|
||||
std::fill_n(offset, remainingLength, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +183,7 @@ size_t SawyerChunkReader::DecodeChunkRLE(void * dst, size_t dstCapacity, const v
|
|||
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
|
||||
}
|
||||
|
||||
Memory::Set(dst8, src8[i], count);
|
||||
std::fill_n(dst8, count, src8[i]);
|
||||
dst8 += count;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include "../core/FileStream.hpp"
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/String.hpp"
|
||||
|
@ -169,7 +171,7 @@ void S6Exporter::Export()
|
|||
// RCT2 uses (void *)-1 to mark NULL. Make sure it's written in a vanilla-compatible way.
|
||||
if (entryData == nullptr || entryData == (void *)-1)
|
||||
{
|
||||
Memory::Set(&_s6.objects[i], 0xFF, sizeof(rct_object_entry));
|
||||
std::memset(&_s6.objects[i], 0xFF, sizeof(rct_object_entry));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -432,7 +434,7 @@ void S6Exporter::ExportRides()
|
|||
{
|
||||
auto src = get_ride(index);
|
||||
auto dst = &_s6.rides[index];
|
||||
Memory::Set(dst, 0, sizeof(rct2_ride));
|
||||
*dst = { 0 };
|
||||
if (src->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
dst->type = RIDE_TYPE_NULL;
|
||||
|
@ -655,7 +657,10 @@ void S6Exporter::ExportRide(rct2_ride * dst, const Ride * src)
|
|||
|
||||
void S6Exporter::ExportResearchedRideTypes()
|
||||
{
|
||||
Memory::Set(_s6.researched_ride_types, false, sizeof(_s6.researched_ride_types));
|
||||
std::fill(
|
||||
std::begin(_s6.researched_ride_types),
|
||||
std::end(_s6.researched_ride_types),
|
||||
false);
|
||||
|
||||
for (sint32 rideType = 0; rideType < RIDE_TYPE_COUNT; rideType++)
|
||||
{
|
||||
|
@ -670,7 +675,10 @@ void S6Exporter::ExportResearchedRideTypes()
|
|||
|
||||
void S6Exporter::ExportResearchedRideEntries()
|
||||
{
|
||||
Memory::Set(_s6.researched_ride_entries, false, sizeof(_s6.researched_ride_entries));
|
||||
std::fill(
|
||||
std::begin(_s6.researched_ride_entries),
|
||||
std::end(_s6.researched_ride_entries),
|
||||
false);
|
||||
|
||||
for (sint32 rideEntryIndex = 0; rideEntryIndex < MAX_RIDE_OBJECTS; rideEntryIndex++)
|
||||
{
|
||||
|
@ -685,7 +693,10 @@ void S6Exporter::ExportResearchedRideEntries()
|
|||
|
||||
void S6Exporter::ExportResearchedSceneryItems()
|
||||
{
|
||||
Memory::Set(_s6.researched_scenery_items, false, sizeof(_s6.researched_scenery_items));
|
||||
std::fill(
|
||||
std::begin(_s6.researched_scenery_items),
|
||||
std::end(_s6.researched_scenery_items),
|
||||
false);
|
||||
|
||||
for (uint16 sceneryEntryIndex = 0; sceneryEntryIndex < RCT2_MAX_RESEARCHED_SCENERY_ITEMS; sceneryEntryIndex++)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/FileStream.hpp"
|
||||
#include "../core/IStream.hpp"
|
||||
|
@ -66,7 +67,7 @@ private:
|
|||
IObjectManager * const _objectManager;
|
||||
|
||||
const utf8 * _s6Path = nullptr;
|
||||
rct_s6_data _s6;
|
||||
rct_s6_data _s6 = { 0 };
|
||||
uint8 _gameVersion = 0;
|
||||
|
||||
public:
|
||||
|
@ -74,7 +75,6 @@ public:
|
|||
: _objectRepository(objectRepository),
|
||||
_objectManager(objectManager)
|
||||
{
|
||||
Memory::Set(&_s6, 0, sizeof(_s6));
|
||||
}
|
||||
|
||||
ParkLoadResult Load(const utf8 * path) override
|
||||
|
@ -187,7 +187,7 @@ public:
|
|||
|
||||
bool GetDetails(scenario_index_entry * dst) override
|
||||
{
|
||||
Memory::Set(dst, 0, sizeof(scenario_index_entry));
|
||||
*dst = { 0 };
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ public:
|
|||
{
|
||||
auto src = &_s6.rides[index];
|
||||
auto dst = get_ride(index);
|
||||
Memory::Set(dst, 0, sizeof(Ride));
|
||||
*dst = { 0 };
|
||||
if (src->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
dst->type = RIDE_TYPE_NULL;
|
||||
|
|
|
@ -47,7 +47,7 @@ extern "C"
|
|||
TitleSequence * CreateTitleSequence()
|
||||
{
|
||||
TitleSequence * seq = Memory::Allocate<TitleSequence>();
|
||||
Memory::Set(seq, 0, sizeof(TitleSequence));
|
||||
*seq = { 0 };
|
||||
return seq;
|
||||
}
|
||||
|
||||
|
|
|
@ -408,8 +408,8 @@ extern bool gMapVirtualFloorVisible;
|
|||
|
||||
extern uint8 gMapGroundFlags;
|
||||
|
||||
extern rct_tile_element gTileElements[];
|
||||
extern rct_tile_element *gTileElementTilePointers[];
|
||||
extern rct_tile_element gTileElements[MAX_TILE_TILE_ELEMENT_POINTERS * 3];
|
||||
extern rct_tile_element *gTileElementTilePointers[MAX_TILE_TILE_ELEMENT_POINTERS];
|
||||
|
||||
extern LocationXY16 gMapSelectionTiles[300];
|
||||
extern rct2_peep_spawn gPeepSpawns[MAX_PEEP_SPAWNS];
|
||||
|
|
Loading…
Reference in New Issue