mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-16 13:24:02 +02:00
Replace &range[0] with range.data() where appropriate
I had been under the impression that .data() on containers returns a const pointer and so hadn't been using it too much. I was wrong; I think that may be limited to std::basic_string. EDIT: I've checked, even std::basic_string has a non-const .data() since C++17, nice.
This commit is contained in:
@@ -46,7 +46,7 @@ void Client::MigrateStampsDef()
|
|||||||
}
|
}
|
||||||
for (auto i = 0; i < int(data.size()); i += 10)
|
for (auto i = 0; i < int(data.size()); i += 10)
|
||||||
{
|
{
|
||||||
stampIDs.push_back(ByteString(&data[0] + i, &data[0] + i + 10));
|
stampIDs.push_back(ByteString(data.data() + i, data.data() + i + 10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -439,7 +439,12 @@ void GameSave::readOPS(const std::vector<char> &data)
|
|||||||
|
|
||||||
Renderer::PopulateTables();
|
Renderer::PopulateTables();
|
||||||
|
|
||||||
unsigned char *inputData = (unsigned char*)&data[0], *partsData = NULL, *partsPosData = NULL, *fanData = NULL, *wallData = NULL, *soapLinkData = NULL;
|
auto *inputData = reinterpret_cast<const unsigned char *>(data.data());
|
||||||
|
unsigned char *partsData = nullptr;
|
||||||
|
unsigned char *partsPosData = nullptr;
|
||||||
|
unsigned char *fanData = nullptr;
|
||||||
|
unsigned char *wallData = nullptr;
|
||||||
|
unsigned char *soapLinkData = nullptr;
|
||||||
unsigned char *pressData = NULL, *vxData = NULL, *vyData = NULL, *ambientData = NULL, *blockAirData = nullptr, *gravityData = nullptr;
|
unsigned char *pressData = NULL, *vxData = NULL, *vyData = NULL, *ambientData = NULL, *blockAirData = nullptr, *gravityData = nullptr;
|
||||||
unsigned int inputDataLen = data.size(), bsonDataLen = 0, partsDataLen, partsPosDataLen, fanDataLen, wallDataLen, soapLinkDataLen;
|
unsigned int inputDataLen = data.size(), bsonDataLen = 0, partsDataLen, partsPosDataLen, fanDataLen, wallDataLen, soapLinkDataLen;
|
||||||
unsigned int pressDataLen, vxDataLen, vyDataLen, ambientDataLen, blockAirDataLen, gravityDataLen;
|
unsigned int pressDataLen, vxDataLen, vyDataLen, ambientDataLen, blockAirDataLen, gravityDataLen;
|
||||||
@@ -1314,7 +1319,7 @@ void GameSave::readPSv(const std::vector<char> &dataVec)
|
|||||||
auto &builtinGol = SimulationData::builtinGol;
|
auto &builtinGol = SimulationData::builtinGol;
|
||||||
Renderer::PopulateTables();
|
Renderer::PopulateTables();
|
||||||
|
|
||||||
unsigned char * saveData = (unsigned char *)&dataVec[0];
|
auto *saveData = reinterpret_cast<const unsigned char *>(dataVec.data());
|
||||||
auto dataLength = int(dataVec.size());
|
auto dataLength = int(dataVec.size());
|
||||||
int q,p=0, pty, ty, legacy_beta=0;
|
int q,p=0, pty, ty, legacy_beta=0;
|
||||||
Vec2<int> blockP = { 0, 0 };
|
Vec2<int> blockP = { 0, 0 };
|
||||||
@@ -1388,7 +1393,7 @@ void GameSave::readPSv(const std::vector<char> &dataVec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSize(blockS);
|
setSize(blockS);
|
||||||
const auto *data = reinterpret_cast<unsigned char *>(&bsonData[0]);
|
const auto *data = reinterpret_cast<const unsigned char *>(bsonData.data());
|
||||||
dataLength = bsonData.size();
|
dataLength = bsonData.size();
|
||||||
|
|
||||||
if constexpr (DEBUG)
|
if constexpr (DEBUG)
|
||||||
@@ -1509,7 +1514,7 @@ void GameSave::readPSv(const std::vector<char> &dataVec)
|
|||||||
}
|
}
|
||||||
if (j)
|
if (j)
|
||||||
{
|
{
|
||||||
memset(&particles[0]+k, 0, sizeof(Particle));
|
memset(&particles[k], 0, sizeof(Particle));
|
||||||
particles[k].type = j;
|
particles[k].type = j;
|
||||||
if (j == PT_COAL)
|
if (j == PT_COAL)
|
||||||
particles[k].tmp = 50;
|
particles[k].tmp = 50;
|
||||||
@@ -1920,7 +1925,7 @@ void GameSave::readPSv(const std::vector<char> &dataVec)
|
|||||||
throw ParseException(ParseException::Corrupt, "Not enough data at line " MTOS(__LINE__) " in " MTOS(__FILE__));
|
throw ParseException(ParseException::Corrupt, "Not enough data at line " MTOS(__LINE__) " in " MTOS(__FILE__));
|
||||||
if(l>254)
|
if(l>254)
|
||||||
l = 254;
|
l = 254;
|
||||||
memcpy(tempSignText, &data[0]+p, l);
|
memcpy(tempSignText, &data[p], l);
|
||||||
tempSignText[l] = 0;
|
tempSignText[l] = 0;
|
||||||
p += l;
|
p += l;
|
||||||
}
|
}
|
||||||
@@ -1981,14 +1986,14 @@ std::pair<bool, std::vector<char>> GameSave::serialiseOPS() const
|
|||||||
std::vector<unsigned char> ambientData(blockSize.X*blockSize.Y*2, 0);
|
std::vector<unsigned char> ambientData(blockSize.X*blockSize.Y*2, 0);
|
||||||
|
|
||||||
std::vector<unsigned char> blockAirData(blockSize.X * blockSize.Y * 2);
|
std::vector<unsigned char> blockAirData(blockSize.X * blockSize.Y * 2);
|
||||||
PlaneAdapter<PlaneBase<unsigned char>> blockAirDataPlane (blockSize, std::in_place, &blockAirData[0] );
|
PlaneAdapter<PlaneBase<unsigned char>> blockAirDataPlane (blockSize, std::in_place, blockAirData.data() );
|
||||||
PlaneAdapter<PlaneBase<unsigned char>> blockAirhDataPlane(blockSize, std::in_place, &blockAirData[0] + blockSize.X * blockSize.Y);
|
PlaneAdapter<PlaneBase<unsigned char>> blockAirhDataPlane(blockSize, std::in_place, blockAirData.data() + blockSize.X * blockSize.Y);
|
||||||
|
|
||||||
std::vector<unsigned char> gravityData(blockSize.X * blockSize.Y * 4 * sizeof(float));
|
std::vector<unsigned char> gravityData(blockSize.X * blockSize.Y * 4 * sizeof(float));
|
||||||
PlaneAdapter<PlaneBase<float >> massDataPlane (blockSize, std::in_place, reinterpret_cast<float *>(&gravityData[0] ));
|
PlaneAdapter<PlaneBase<float >> massDataPlane (blockSize, std::in_place, reinterpret_cast<float *>(gravityData.data() ));
|
||||||
PlaneAdapter<PlaneBase<uint32_t>> maskDataPlane (blockSize, std::in_place, reinterpret_cast<uint32_t *>(&gravityData[0] + blockSize.X * blockSize.Y * sizeof(float)));
|
PlaneAdapter<PlaneBase<uint32_t>> maskDataPlane (blockSize, std::in_place, reinterpret_cast<uint32_t *>(gravityData.data() + blockSize.X * blockSize.Y * sizeof(float)));
|
||||||
PlaneAdapter<PlaneBase<float >> forceXDataPlane(blockSize, std::in_place, reinterpret_cast<float *>(&gravityData[0] + 2 * blockSize.X * blockSize.Y * sizeof(float)));
|
PlaneAdapter<PlaneBase<float >> forceXDataPlane(blockSize, std::in_place, reinterpret_cast<float *>(gravityData.data() + 2 * blockSize.X * blockSize.Y * sizeof(float)));
|
||||||
PlaneAdapter<PlaneBase<float >> forceYDataPlane(blockSize, std::in_place, reinterpret_cast<float *>(&gravityData[0] + 3 * blockSize.X * blockSize.Y * sizeof(float)));
|
PlaneAdapter<PlaneBase<float >> forceYDataPlane(blockSize, std::in_place, reinterpret_cast<float *>(gravityData.data() + 3 * blockSize.X * blockSize.Y * sizeof(float)));
|
||||||
|
|
||||||
unsigned int wallDataLen = blockSize.X*blockSize.Y, fanDataLen = 0, pressDataLen = 0, vxDataLen = 0, vyDataLen = 0, ambientDataLen = 0;
|
unsigned int wallDataLen = blockSize.X*blockSize.Y, fanDataLen = 0, pressDataLen = 0, vxDataLen = 0, vyDataLen = 0, ambientDataLen = 0;
|
||||||
|
|
||||||
@@ -2115,7 +2120,7 @@ std::pair<bool, std::vector<char>> GameSave::serialiseOPS() const
|
|||||||
unsigned int partsDataLen = 0;
|
unsigned int partsDataLen = 0;
|
||||||
std::vector<unsigned> partsSaveIndex(NPART);
|
std::vector<unsigned> partsSaveIndex(NPART);
|
||||||
unsigned int partsCount = 0;
|
unsigned int partsCount = 0;
|
||||||
std::fill(&partsSaveIndex[0], &partsSaveIndex[0] + NPART, 0);
|
std::fill(partsSaveIndex.data(), partsSaveIndex.data() + NPART, 0);
|
||||||
auto &sd = SimulationData::CRef();
|
auto &sd = SimulationData::CRef();
|
||||||
auto &elements = sd.elements;
|
auto &elements = sd.elements;
|
||||||
std::set<int> paletteSet;
|
std::set<int> paletteSet;
|
||||||
@@ -2539,7 +2544,7 @@ std::pair<bool, std::vector<char>> GameSave::serialiseOPS() const
|
|||||||
bson_append_int(&b, "pmapbits", pmapbits);
|
bson_append_int(&b, "pmapbits", pmapbits);
|
||||||
if (partsDataLen)
|
if (partsDataLen)
|
||||||
{
|
{
|
||||||
bson_append_binary(&b, "parts", (char)BSON_BIN_USER, (const char *)&partsData[0], partsDataLen);
|
bson_append_binary(&b, "parts", (char)BSON_BIN_USER, reinterpret_cast<const char *>(partsData.data()), partsDataLen);
|
||||||
|
|
||||||
if (paletteData.size())
|
if (paletteData.size())
|
||||||
{
|
{
|
||||||
@@ -2552,33 +2557,33 @@ std::pair<bool, std::vector<char>> GameSave::serialiseOPS() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (partsPosDataLen)
|
if (partsPosDataLen)
|
||||||
bson_append_binary(&b, "partsPos", (char)BSON_BIN_USER, (const char *)&partsPosData[0], partsPosDataLen);
|
bson_append_binary(&b, "partsPos", (char)BSON_BIN_USER, reinterpret_cast<const char *>(partsPosData.data()), partsPosDataLen);
|
||||||
}
|
}
|
||||||
if (hasWallData)
|
if (hasWallData)
|
||||||
bson_append_binary(&b, "wallMap", (char)BSON_BIN_USER, (const char *)wallData.data(), wallDataLen);
|
bson_append_binary(&b, "wallMap", (char)BSON_BIN_USER, (const char *)wallData.data(), wallDataLen);
|
||||||
if (fanDataLen)
|
if (fanDataLen)
|
||||||
bson_append_binary(&b, "fanMap", (char)BSON_BIN_USER, (const char *)&fanData[0], fanDataLen);
|
bson_append_binary(&b, "fanMap", (char)BSON_BIN_USER, reinterpret_cast<const char *>(fanData.data()), fanDataLen);
|
||||||
if (hasPressure && pressDataLen)
|
if (hasPressure && pressDataLen)
|
||||||
bson_append_binary(&b, "pressMap", (char)BSON_BIN_USER, (const char*)&pressData[0], pressDataLen);
|
bson_append_binary(&b, "pressMap", (char)BSON_BIN_USER, reinterpret_cast<const char *>(pressData.data()), pressDataLen);
|
||||||
if (hasPressure && vxDataLen)
|
if (hasPressure && vxDataLen)
|
||||||
bson_append_binary(&b, "vxMap", (char)BSON_BIN_USER, (const char*)&vxData[0], vxDataLen);
|
bson_append_binary(&b, "vxMap", (char)BSON_BIN_USER, reinterpret_cast<const char *>(vxData.data()), vxDataLen);
|
||||||
if (hasPressure && vyDataLen)
|
if (hasPressure && vyDataLen)
|
||||||
bson_append_binary(&b, "vyMap", (char)BSON_BIN_USER, (const char*)&vyData[0], vyDataLen);
|
bson_append_binary(&b, "vyMap", (char)BSON_BIN_USER, reinterpret_cast<const char *>(vyData.data()), vyDataLen);
|
||||||
if (hasAmbientHeat && this->aheatEnable && ambientDataLen)
|
if (hasAmbientHeat && this->aheatEnable && ambientDataLen)
|
||||||
bson_append_binary(&b, "ambientMap", (char)BSON_BIN_USER, (const char*)&ambientData[0], ambientDataLen);
|
bson_append_binary(&b, "ambientMap", (char)BSON_BIN_USER, reinterpret_cast<const char *>(ambientData.data()), ambientDataLen);
|
||||||
if (soapLinkDataLen)
|
if (soapLinkDataLen)
|
||||||
bson_append_binary(&b, "soapLinks", (char)BSON_BIN_USER, (const char *)&soapLinkData[0], soapLinkDataLen);
|
bson_append_binary(&b, "soapLinks", (char)BSON_BIN_USER, reinterpret_cast<const char *>(soapLinkData.data()), soapLinkDataLen);
|
||||||
bson_append_binary(&b, "blockAir", (char)BSON_BIN_USER, (const char *)blockAirData.data(), blockAirData.size());
|
bson_append_binary(&b, "blockAir", (char)BSON_BIN_USER, reinterpret_cast<const char *>(blockAirData.data()), blockAirData.size());
|
||||||
if (ensureDeterminism)
|
if (ensureDeterminism)
|
||||||
{
|
{
|
||||||
bson_append_bool(&b, "ensureDeterminism", ensureDeterminism);
|
bson_append_bool(&b, "ensureDeterminism", ensureDeterminism);
|
||||||
bson_append_long(&b, "frameCount", int64_t(frameCount));
|
bson_append_long(&b, "frameCount", int64_t(frameCount));
|
||||||
bson_append_binary(&b, "rngState", (char)BSON_BIN_USER, (const char *)&rngState, sizeof(rngState));
|
bson_append_binary(&b, "rngState", (char)BSON_BIN_USER, reinterpret_cast<const char *>(&rngState), sizeof(rngState));
|
||||||
RESTRICTVERSION(98, 0);
|
RESTRICTVERSION(98, 0);
|
||||||
}
|
}
|
||||||
if (gravityEnable)
|
if (gravityEnable)
|
||||||
{
|
{
|
||||||
bson_append_binary(&b, "gravity", (char)BSON_BIN_USER, (const char *)gravityData.data(), gravityData.size());
|
bson_append_binary(&b, "gravity", (char)BSON_BIN_USER, reinterpret_cast<const char *>(gravityData.data()), gravityData.size());
|
||||||
}
|
}
|
||||||
unsigned int signsCount = 0;
|
unsigned int signsCount = 0;
|
||||||
for (size_t i = 0; i < signs.size(); i++)
|
for (size_t i = 0; i < signs.size(); i++)
|
||||||
|
@@ -77,7 +77,7 @@ namespace http
|
|||||||
if (doOnce.allPems.size())
|
if (doOnce.allPems.size())
|
||||||
{
|
{
|
||||||
curl_blob blob;
|
curl_blob blob;
|
||||||
blob.data = &doOnce.allPems[0];
|
blob.data = doOnce.allPems.data();
|
||||||
blob.len = doOnce.allPems.size();
|
blob.len = doOnce.allPems.size();
|
||||||
blob.flags = CURL_BLOB_COPY;
|
blob.flags = CURL_BLOB_COPY;
|
||||||
HandleCURLcode(curl_easy_setopt(easy, CURLOPT_CAINFO_BLOB, &blob));
|
HandleCURLcode(curl_easy_setopt(easy, CURLOPT_CAINFO_BLOB, &blob));
|
||||||
|
@@ -190,7 +190,7 @@ namespace http
|
|||||||
new Blob([ HEAP8.slice($2, $2 + $3) ]),
|
new Blob([ HEAP8.slice($2, $2 + $3) ]),
|
||||||
UTF8ToString($4)
|
UTF8ToString($4)
|
||||||
);
|
);
|
||||||
}, handle->id, field.name.c_str(), &field.value[0], field.value.size(), field.filename->c_str());
|
}, handle->id, field.name.c_str(), field.value.data(), field.value.size(), field.filename->c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -212,7 +212,7 @@ namespace http
|
|||||||
HEAP8.byteOffset + $1,
|
HEAP8.byteOffset + $1,
|
||||||
$2
|
$2
|
||||||
);
|
);
|
||||||
}, handle->id, &stringData[0], stringData.size());
|
}, handle->id, stringData.data(), stringData.size());
|
||||||
}
|
}
|
||||||
if (handle->isPost)
|
if (handle->isPost)
|
||||||
{
|
{
|
||||||
@@ -328,7 +328,7 @@ namespace http
|
|||||||
EM_ASM({
|
EM_ASM({
|
||||||
let responseData = Module.emscriptenRequestManager.requests[$0].responseData;
|
let responseData = Module.emscriptenRequestManager.requests[$0].responseData;
|
||||||
writeArrayToMemory(new Int8Array(responseData), $1);
|
writeArrayToMemory(new Int8Array(responseData), $1);
|
||||||
}, handle->id, &handle->responseData[0]);
|
}, handle->id, handle->responseData.data());
|
||||||
}
|
}
|
||||||
auto headerCount = EM_ASM_INT({
|
auto headerCount = EM_ASM_INT({
|
||||||
let responseHeaders = Module.emscriptenRequestManager.requests[$0].responseHeaders;
|
let responseHeaders = Module.emscriptenRequestManager.requests[$0].responseHeaders;
|
||||||
|
@@ -415,7 +415,7 @@ namespace http
|
|||||||
// Hopefully this is what a NULL from curl_mime_addpart means.
|
// Hopefully this is what a NULL from curl_mime_addpart means.
|
||||||
HandleCURLcode(CURLE_OUT_OF_MEMORY);
|
HandleCURLcode(CURLE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
HandleCURLcode(curl_mime_data(part, &field.value[0], field.value.size()));
|
HandleCURLcode(curl_mime_data(part, field.value.data(), field.value.size()));
|
||||||
HandleCURLcode(curl_mime_name(part, field.name.c_str()));
|
HandleCURLcode(curl_mime_name(part, field.name.c_str()));
|
||||||
if (field.filename.has_value())
|
if (field.filename.has_value())
|
||||||
{
|
{
|
||||||
@@ -431,7 +431,7 @@ namespace http
|
|||||||
HandleCURLFORMcode(curl_formadd(&handle->curlPostFieldsFirst, &handle->curlPostFieldsLast,
|
HandleCURLFORMcode(curl_formadd(&handle->curlPostFieldsFirst, &handle->curlPostFieldsLast,
|
||||||
CURLFORM_COPYNAME, field.name.c_str(),
|
CURLFORM_COPYNAME, field.name.c_str(),
|
||||||
CURLFORM_BUFFER, field.filename->c_str(),
|
CURLFORM_BUFFER, field.filename->c_str(),
|
||||||
CURLFORM_BUFFERPTR, &field.value[0],
|
CURLFORM_BUFFERPTR, field.value.data(),
|
||||||
CURLFORM_BUFFERLENGTH, field.value.size(),
|
CURLFORM_BUFFERLENGTH, field.value.size(),
|
||||||
CURLFORM_END));
|
CURLFORM_END));
|
||||||
}
|
}
|
||||||
@@ -439,7 +439,7 @@ namespace http
|
|||||||
{
|
{
|
||||||
HandleCURLFORMcode(curl_formadd(&handle->curlPostFieldsFirst, &handle->curlPostFieldsLast,
|
HandleCURLFORMcode(curl_formadd(&handle->curlPostFieldsFirst, &handle->curlPostFieldsLast,
|
||||||
CURLFORM_COPYNAME, field.name.c_str(),
|
CURLFORM_COPYNAME, field.name.c_str(),
|
||||||
CURLFORM_PTRCONTENTS, &field.value[0],
|
CURLFORM_PTRCONTENTS, field.value.data(),
|
||||||
CURLFORM_CONTENTLEN, field.value.size(),
|
CURLFORM_CONTENTLEN, field.value.size(),
|
||||||
CURLFORM_END));
|
CURLFORM_END));
|
||||||
}
|
}
|
||||||
@@ -450,7 +450,7 @@ namespace http
|
|||||||
else if (std::holds_alternative<http::StringData>(postData) && std::get<http::StringData>(postData).size())
|
else if (std::holds_alternative<http::StringData>(postData) && std::get<http::StringData>(postData).size())
|
||||||
{
|
{
|
||||||
auto &stringData = std::get<http::StringData>(postData);
|
auto &stringData = std::get<http::StringData>(postData);
|
||||||
HandleCURLcode(curl_easy_setopt(handle->curlEasy, CURLOPT_POSTFIELDS, &stringData[0]));
|
HandleCURLcode(curl_easy_setopt(handle->curlEasy, CURLOPT_POSTFIELDS, stringData.data()));
|
||||||
HandleCURLcode(curl_easy_setopt(handle->curlEasy, CURLOPT_POSTFIELDSIZE_LARGE, curl_off_t(stringData.size())));
|
HandleCURLcode(curl_easy_setopt(handle->curlEasy, CURLOPT_POSTFIELDSIZE_LARGE, curl_off_t(stringData.size())));
|
||||||
}
|
}
|
||||||
else if (handle->isPost)
|
else if (handle->isPost)
|
||||||
|
@@ -64,11 +64,11 @@ namespace http
|
|||||||
}
|
}
|
||||||
std::vector<char> pem(pemLength);
|
std::vector<char> pem(pemLength);
|
||||||
// actually get the data
|
// actually get the data
|
||||||
if (!CryptBinaryToStringA(context->pbCertEncoded, context->cbCertEncoded, CRYPT_STRING_BASE64HEADER, &pem[0], &pemLength))
|
if (!CryptBinaryToStringA(context->pbCertEncoded, context->cbCertEncoded, CRYPT_STRING_BASE64HEADER, pem.data(), &pemLength))
|
||||||
{
|
{
|
||||||
return die("CryptBinaryToStringA failed");
|
return die("CryptBinaryToStringA failed");
|
||||||
}
|
}
|
||||||
allPems += ByteString(&pem[0], &pem[0] + pem.size() - 1); // buffer includes the zero terminator, omit that
|
allPems += ByteString(pem.data(), pem.data() + pem.size() - 1); // buffer includes the zero terminator, omit that
|
||||||
}
|
}
|
||||||
if (!allPems.size())
|
if (!allPems.size())
|
||||||
{
|
{
|
||||||
@@ -86,7 +86,7 @@ namespace http
|
|||||||
if (doOnce.allPems.size())
|
if (doOnce.allPems.size())
|
||||||
{
|
{
|
||||||
curl_blob blob;
|
curl_blob blob;
|
||||||
blob.data = &doOnce.allPems[0];
|
blob.data = doOnce.allPems.data();
|
||||||
blob.len = doOnce.allPems.size();
|
blob.len = doOnce.allPems.size();
|
||||||
blob.flags = CURL_BLOB_COPY;
|
blob.flags = CURL_BLOB_COPY;
|
||||||
HandleCURLcode(curl_easy_setopt(easy, CURLOPT_CAINFO_BLOB, &blob));
|
HandleCURLcode(curl_easy_setopt(easy, CURLOPT_CAINFO_BLOB, &blob));
|
||||||
|
@@ -19,7 +19,7 @@ namespace Clipboard
|
|||||||
changeCount = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
changeCount = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||||
std::vector<char> saveData;
|
std::vector<char> saveData;
|
||||||
SerializeClipboard(saveData);
|
SerializeClipboard(saveData);
|
||||||
const auto *base = &saveData[0];
|
const auto *base = saveData.data();
|
||||||
auto size = saveData.size();
|
auto size = saveData.size();
|
||||||
NSData *data = [NSData dataWithBytes:base length:size];
|
NSData *data = [NSData dataWithBytes:base length:size];
|
||||||
if (![pasteboard setData:data forType:format])
|
if (![pasteboard setData:data forType:format])
|
||||||
|
@@ -141,7 +141,7 @@ namespace Clipboard
|
|||||||
auto bail = false;
|
auto bail = false;
|
||||||
std::vector<char> saveData;
|
std::vector<char> saveData;
|
||||||
SerializeClipboard(saveData);
|
SerializeClipboard(saveData);
|
||||||
if (fwrite(&saveData[0], 1, saveData.size(), handle) != saveData.size())
|
if (fwrite(saveData.data(), 1, saveData.size(), handle) != saveData.size())
|
||||||
{
|
{
|
||||||
std::cerr << "failed to set clipboard data: fwrite: " << strerror(errno) << std::endl;
|
std::cerr << "failed to set clipboard data: fwrite: " << strerror(errno) << std::endl;
|
||||||
bail = true;
|
bail = true;
|
||||||
|
@@ -58,7 +58,7 @@ bool ReadFile(std::vector<char> &fileData, ByteString filename)
|
|||||||
if (f) f.seekg(0, std::ios::end);
|
if (f) f.seekg(0, std::ios::end);
|
||||||
if (f) fileData.resize(f.tellg());
|
if (f) fileData.resize(f.tellg());
|
||||||
if (f) f.seekg(0);
|
if (f) f.seekg(0);
|
||||||
if (f && fileData.size()) f.read(&fileData[0], fileData.size());
|
if (f && fileData.size()) f.read(fileData.data(), fileData.size());
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
std::cerr << "ReadFile: " << filename << ": " << strerror(errno) << std::endl;
|
std::cerr << "ReadFile: " << filename << ": " << strerror(errno) << std::endl;
|
||||||
@@ -85,7 +85,7 @@ bool WriteFile(const std::vector<char> &fileData, ByteString filename)
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
{
|
{
|
||||||
std::ofstream f(writeFileName, std::ios::binary);
|
std::ofstream f(writeFileName, std::ios::binary);
|
||||||
if (f) f.write(&fileData[0], fileData.size());
|
if (f) f.write(fileData.data(), fileData.size());
|
||||||
ok = bool(f);
|
ok = bool(f);
|
||||||
}
|
}
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
@@ -27,12 +27,12 @@ ByteString ExecutableNameFirstApprox()
|
|||||||
ByteString firstApproximation("?");
|
ByteString firstApproximation("?");
|
||||||
{
|
{
|
||||||
auto bufSize = uint32_t(firstApproximation.size());
|
auto bufSize = uint32_t(firstApproximation.size());
|
||||||
auto ret = _NSGetExecutablePath(&firstApproximation[0], &bufSize);
|
auto ret = _NSGetExecutablePath(firstApproximation.data(), &bufSize);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
// Buffer not large enough; likely to happen since it's initially a single byte.
|
// Buffer not large enough; likely to happen since it's initially a single byte.
|
||||||
firstApproximation.resize(bufSize);
|
firstApproximation.resize(bufSize);
|
||||||
ret = _NSGetExecutablePath(&firstApproximation[0], &bufSize);
|
ret = _NSGetExecutablePath(firstApproximation.data(), &bufSize);
|
||||||
}
|
}
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
|
@@ -42,9 +42,9 @@ ByteString ExecutableNameFirstApprox()
|
|||||||
mib[3] = -1;
|
mib[3] = -1;
|
||||||
std::array<char, 1000> buf;
|
std::array<char, 1000> buf;
|
||||||
size_t cb = buf.size();
|
size_t cb = buf.size();
|
||||||
if (!sysctl(mib, 4, &buf[0], &cb, NULL, 0))
|
if (!sysctl(mib, 4, buf.data(), &cb, NULL, 0))
|
||||||
{
|
{
|
||||||
return ByteString(&buf[0], &buf[0] + cb);
|
return ByteString(buf.data(), buf.data() + cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -28,7 +28,7 @@ void DoRestart()
|
|||||||
ByteString ExecutableName()
|
ByteString ExecutableName()
|
||||||
{
|
{
|
||||||
auto firstApproximation = ExecutableNameFirstApprox();
|
auto firstApproximation = ExecutableNameFirstApprox();
|
||||||
auto rp = std::unique_ptr<char, decltype(std::free) *>(realpath(&firstApproximation[0], NULL), std::free);
|
auto rp = std::unique_ptr<char, decltype(std::free) *>(realpath(firstApproximation.data(), NULL), std::free);
|
||||||
if (!rp)
|
if (!rp)
|
||||||
{
|
{
|
||||||
std::cerr << "realpath: " << errno << std::endl;
|
std::cerr << "realpath: " << errno << std::endl;
|
||||||
|
@@ -173,7 +173,7 @@ ByteString WinNarrow(const std::wstring &source)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::string output(buffer_size, 0);
|
std::string output(buffer_size, 0);
|
||||||
if (!WideCharToMultiByte(CP_UTF8, 0, source.c_str(), source.size(), &output[0], buffer_size, NULL, NULL))
|
if (!WideCharToMultiByte(CP_UTF8, 0, source.c_str(), source.size(), output.data(), buffer_size, NULL, NULL))
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ std::wstring WinWiden(const ByteString &source)
|
|||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
std::wstring output(buffer_size, 0);
|
std::wstring output(buffer_size, 0);
|
||||||
if (!MultiByteToWideChar(CP_UTF8, 0, source.c_str(), source.size(), &output[0], buffer_size))
|
if (!MultiByteToWideChar(CP_UTF8, 0, source.c_str(), source.size(), output.data(), buffer_size))
|
||||||
{
|
{
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ ByteString ExecutableName()
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
if (!GetModuleFileNameW(NULL, &buf[0], DWORD(buf.size())))
|
if (!GetModuleFileNameW(NULL, buf.data(), DWORD(buf.size())))
|
||||||
{
|
{
|
||||||
std::cerr << "GetModuleFileNameW: " << GetLastError() << std::endl;
|
std::cerr << "GetModuleFileNameW: " << GetLastError() << std::endl;
|
||||||
return "";
|
return "";
|
||||||
@@ -212,7 +212,7 @@ ByteString ExecutableName()
|
|||||||
}
|
}
|
||||||
buf.resize(buf.size() * 2);
|
buf.resize(buf.size() * 2);
|
||||||
}
|
}
|
||||||
return WinNarrow(&buf[0]); // Pass pointer to copy only up to the zero terminator.
|
return WinNarrow(buf.data()); // Pass pointer to copy only up to the zero terminator.
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoRestart()
|
void DoRestart()
|
||||||
|
@@ -11,8 +11,8 @@ namespace Platform
|
|||||||
std::optional<std::vector<String>> StackTrace()
|
std::optional<std::vector<String>> StackTrace()
|
||||||
{
|
{
|
||||||
std::array<void *, 100> buf;
|
std::array<void *, 100> buf;
|
||||||
auto used = backtrace(&buf[0], buf.size());
|
auto used = backtrace(buf.data(), buf.size());
|
||||||
auto *strs = backtrace_symbols(&buf[0], used);
|
auto *strs = backtrace_symbols(buf.data(), used);
|
||||||
Defer freeStrs([strs]() {
|
Defer freeStrs([strs]() {
|
||||||
free(strs);
|
free(strs);
|
||||||
});
|
});
|
||||||
|
@@ -20,7 +20,7 @@ static std::optional<SymbolInfo> GetSymbolInfo(HANDLE process, uintptr_t offset)
|
|||||||
{
|
{
|
||||||
DWORD64 displacement;
|
DWORD64 displacement;
|
||||||
std::array<char, sizeof(SYMBOL_INFOW) + 1000> symbolData{};
|
std::array<char, sizeof(SYMBOL_INFOW) + 1000> symbolData{};
|
||||||
auto &symbol = *reinterpret_cast<SYMBOL_INFOW *>(&symbolData[0]);
|
auto &symbol = *reinterpret_cast<SYMBOL_INFOW *>(symbolData.data());
|
||||||
symbol.SizeOfStruct = sizeof(symbol);
|
symbol.SizeOfStruct = sizeof(symbol);
|
||||||
symbol.MaxNameLen = symbolData.size() - sizeof(symbol);
|
symbol.MaxNameLen = symbolData.size() - sizeof(symbol);
|
||||||
if (SymFromAddrW(process, offset, &displacement, &symbol))
|
if (SymFromAddrW(process, offset, &displacement, &symbol))
|
||||||
|
@@ -29,9 +29,9 @@ static bool InitFontData()
|
|||||||
}
|
}
|
||||||
int first = -1;
|
int first = -1;
|
||||||
int last = -1;
|
int last = -1;
|
||||||
char *begin = &fontDataBuf[0];
|
char *begin = fontDataBuf.data();
|
||||||
char *ptr = &fontDataBuf[0];
|
char *ptr = fontDataBuf.data();
|
||||||
char *end = &fontDataBuf[0] + fontDataBuf.size();
|
char *end = fontDataBuf.data() + fontDataBuf.size();
|
||||||
while (ptr != end)
|
while (ptr != end)
|
||||||
{
|
{
|
||||||
if (ptr + 4 > end)
|
if (ptr + 4 > end)
|
||||||
|
@@ -28,7 +28,7 @@ void FontEditor::ReadDataFile(ByteString dataFile)
|
|||||||
file.seekg(0, std::ios_base::end);
|
file.seekg(0, std::ios_base::end);
|
||||||
std::vector<char> fileData(file.tellg());
|
std::vector<char> fileData(file.tellg());
|
||||||
file.seekg(0);
|
file.seekg(0);
|
||||||
file.read(&fileData[0], fileData.size());
|
file.read(fileData.data(), fileData.size());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
std::vector<char> fontDataBuf;
|
std::vector<char> fontDataBuf;
|
||||||
@@ -40,9 +40,9 @@ void FontEditor::ReadDataFile(ByteString dataFile)
|
|||||||
}
|
}
|
||||||
int first = -1;
|
int first = -1;
|
||||||
int last = -1;
|
int last = -1;
|
||||||
char *begin = &fontDataBuf[0];
|
char *begin = fontDataBuf.data();
|
||||||
char *ptr = &fontDataBuf[0];
|
char *ptr = fontDataBuf.data();
|
||||||
char *end = &fontDataBuf[0] + fontDataBuf.size();
|
char *end = fontDataBuf.data() + fontDataBuf.size();
|
||||||
while (ptr != end)
|
while (ptr != end)
|
||||||
{
|
{
|
||||||
if (ptr + 4 > end)
|
if (ptr + 4 > end)
|
||||||
|
@@ -61,7 +61,7 @@ GameModel::GameModel():
|
|||||||
sim->useLuaCallbacks = true;
|
sim->useLuaCallbacks = true;
|
||||||
ren = new Renderer(sim);
|
ren = new Renderer(sim);
|
||||||
|
|
||||||
activeTools = ®ularToolset[0];
|
activeTools = regularToolset.data();
|
||||||
|
|
||||||
std::fill(decoToolset.begin(), decoToolset.end(), nullptr);
|
std::fill(decoToolset.begin(), decoToolset.end(), nullptr);
|
||||||
std::fill(regularToolset.begin(), regularToolset.end(), nullptr);
|
std::fill(regularToolset.begin(), regularToolset.end(), nullptr);
|
||||||
@@ -883,17 +883,17 @@ void GameModel::SetActiveMenu(int menuID)
|
|||||||
|
|
||||||
if(menuID == SC_DECO)
|
if(menuID == SC_DECO)
|
||||||
{
|
{
|
||||||
if(activeTools != &decoToolset[0])
|
if(activeTools != decoToolset.data())
|
||||||
{
|
{
|
||||||
activeTools = &decoToolset[0];
|
activeTools = decoToolset.data();
|
||||||
notifyActiveToolsChanged();
|
notifyActiveToolsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(activeTools != ®ularToolset[0])
|
if(activeTools != regularToolset.data())
|
||||||
{
|
{
|
||||||
activeTools = ®ularToolset[0];
|
activeTools = regularToolset.data();
|
||||||
notifyActiveToolsChanged();
|
notifyActiveToolsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -93,7 +93,7 @@ private:
|
|||||||
std::vector<char> res(uncompressedLength);
|
std::vector<char> res(uncompressedLength);
|
||||||
|
|
||||||
int dstate;
|
int dstate;
|
||||||
dstate = BZ2_bzBuffToBuffDecompress(&res[0], (unsigned *)&uncompressedLength, &data[8], data.size()-8, 0, 0);
|
dstate = BZ2_bzBuffToBuffDecompress(res.data(), (unsigned *)&uncompressedLength, &data[8], data.size()-8, 0, 0);
|
||||||
if (dstate)
|
if (dstate)
|
||||||
{
|
{
|
||||||
return niceNotifyError(String::Build("Unable to decompress update: ", dstate));
|
return niceNotifyError(String::Build("Unable to decompress update: ", dstate));
|
||||||
|
@@ -307,7 +307,7 @@ AnyType CommandInterface::tptS_set(std::deque<String> * words)
|
|||||||
AnyType value = eval(words);
|
AnyType value = eval(words);
|
||||||
|
|
||||||
Simulation * sim = m->GetSimulation();
|
Simulation * sim = m->GetSimulation();
|
||||||
unsigned char * partsBlock = (unsigned char*)&sim->parts[0];
|
unsigned char * partsBlock = reinterpret_cast<unsigned char *>(&sim->parts[0]);
|
||||||
|
|
||||||
int returnValue = 0;
|
int returnValue = 0;
|
||||||
|
|
||||||
|
@@ -156,7 +156,7 @@ namespace LuaSocket
|
|||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
if (!tcps->writeClosed)
|
if (!tcps->writeClosed)
|
||||||
{
|
{
|
||||||
res = curl_easy_send(tcps->easy, &data[0] + writtenTotal, len - writtenTotal, &writtenNow);
|
res = curl_easy_send(tcps->easy, data + writtenTotal, len - writtenTotal, &writtenNow);
|
||||||
}
|
}
|
||||||
writtenTotal += writtenNow;
|
writtenTotal += writtenNow;
|
||||||
if (writtenTotal >= len)
|
if (writtenTotal >= len)
|
||||||
@@ -250,7 +250,7 @@ namespace LuaSocket
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = curl_easy_recv(tcps->easy, &tcps->recvBuf[0] + readTotal, len - readTotal, &readNow);
|
res = curl_easy_recv(tcps->easy, tcps->recvBuf.data() + readTotal, len - readTotal, &readNow);
|
||||||
}
|
}
|
||||||
readTotal += readNow;
|
readTotal += readNow;
|
||||||
returning = readTotal;
|
returning = readTotal;
|
||||||
@@ -353,7 +353,7 @@ namespace LuaSocket
|
|||||||
}
|
}
|
||||||
returning = curOut;
|
returning = curOut;
|
||||||
}
|
}
|
||||||
lua_pushlstring(L, &tcps->recvBuf[0], returning);
|
lua_pushlstring(L, tcps->recvBuf.data(), returning);
|
||||||
// * This copy makes ReceiveNoPrefix quadratic if there's a lot of stuff in
|
// * This copy makes ReceiveNoPrefix quadratic if there's a lot of stuff in
|
||||||
// the stash (as a result of a *very* long line being returned by an "*L"
|
// the stash (as a result of a *very* long line being returned by an "*L"
|
||||||
// pattern and then whatever was left being stashed) and it's all *very*
|
// pattern and then whatever was left being stashed) and it's all *very*
|
||||||
@@ -361,9 +361,9 @@ namespace LuaSocket
|
|||||||
// of view of an "*L" pattern). Handling this edge case in a special,
|
// of view of an "*L" pattern). Handling this edge case in a special,
|
||||||
// sub-quadratic way isn't worth the effort.
|
// sub-quadratic way isn't worth the effort.
|
||||||
std::copy(
|
std::copy(
|
||||||
&tcps->recvBuf[0] + readTotal - tcps->stashedLen,
|
tcps->recvBuf.data() + readTotal - tcps->stashedLen,
|
||||||
&tcps->recvBuf[0] + readTotal,
|
tcps->recvBuf.data() + readTotal,
|
||||||
&tcps->recvBuf[0]
|
tcps->recvBuf.data()
|
||||||
);
|
);
|
||||||
return retn;
|
return retn;
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ void Prefs::Read()
|
|||||||
std::cerr << "no json data" << std::endl;
|
std::cerr << "no json data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!reader->parse(&data[0], &data[0] + data.size(), &root, &errs))
|
if (!reader->parse(data.data(), data.data() + data.size(), &root, &errs))
|
||||||
{
|
{
|
||||||
std::cerr << errs << std::endl;
|
std::cerr << errs << std::endl;
|
||||||
return;
|
return;
|
||||||
|
@@ -156,7 +156,7 @@ void FillHunkVectorPtr(const Item *oldItems, const Item *newItems, SnapshotDelta
|
|||||||
template<class Item>
|
template<class Item>
|
||||||
void FillHunkVector(const std::vector<Item> &oldItems, const std::vector<Item> &newItems, SnapshotDelta::HunkVector<Item> &out)
|
void FillHunkVector(const std::vector<Item> &oldItems, const std::vector<Item> &newItems, SnapshotDelta::HunkVector<Item> &out)
|
||||||
{
|
{
|
||||||
FillHunkVectorPtr<Item>(&oldItems[0], &newItems[0], out, std::min(oldItems.size(), newItems.size()));
|
FillHunkVectorPtr<Item>(oldItems.data(), newItems.data(), out, std::min(oldItems.size(), newItems.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Item>
|
template<class Item>
|
||||||
@@ -187,7 +187,7 @@ void ApplyHunkVectorPtr(const SnapshotDelta::HunkVector<Item> &in, Item *items)
|
|||||||
template<bool UseOld, class Item>
|
template<bool UseOld, class Item>
|
||||||
void ApplyHunkVector(const SnapshotDelta::HunkVector<Item> &in, std::vector<Item> &items)
|
void ApplyHunkVector(const SnapshotDelta::HunkVector<Item> &in, std::vector<Item> &items)
|
||||||
{
|
{
|
||||||
ApplyHunkVectorPtr<UseOld, Item>(in, &items[0]);
|
ApplyHunkVectorPtr<UseOld, Item>(in, items.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool UseOld, class Item>
|
template<bool UseOld, class Item>
|
||||||
@@ -221,12 +221,12 @@ std::unique_ptr<SnapshotDelta> SnapshotDelta::FromSnapshots(const Snapshot &oldS
|
|||||||
FillSingleDiff(oldSnap.Authors , newSnap.Authors , delta.Authors );
|
FillSingleDiff(oldSnap.Authors , newSnap.Authors , delta.Authors );
|
||||||
FillSingleDiff(oldSnap.FrameCount , newSnap.FrameCount , delta.FrameCount );
|
FillSingleDiff(oldSnap.FrameCount , newSnap.FrameCount , delta.FrameCount );
|
||||||
FillSingleDiff(oldSnap.RngState , newSnap.RngState , delta.RngState );
|
FillSingleDiff(oldSnap.RngState , newSnap.RngState , delta.RngState );
|
||||||
FillHunkVectorPtr(reinterpret_cast<const uint32_t *>(&oldSnap.PortalParticles[0]), reinterpret_cast<const uint32_t *>(&newSnap.PortalParticles[0]), delta.PortalParticles, newSnap.PortalParticles.size() * ParticleUint32Count);
|
FillHunkVectorPtr(reinterpret_cast<const uint32_t *>(oldSnap.PortalParticles.data()), reinterpret_cast<const uint32_t *>(newSnap.PortalParticles.data()), delta.PortalParticles, newSnap.PortalParticles.size() * ParticleUint32Count);
|
||||||
FillHunkVectorPtr(reinterpret_cast<const uint32_t *>(&oldSnap.stickmen[0]) , reinterpret_cast<const uint32_t *>(&newSnap.stickmen[0] ), delta.stickmen , newSnap.stickmen .size() * playerstUint32Count);
|
FillHunkVectorPtr(reinterpret_cast<const uint32_t *>(oldSnap.stickmen.data()) , reinterpret_cast<const uint32_t *>(newSnap.stickmen.data() ), delta.stickmen , newSnap.stickmen .size() * playerstUint32Count);
|
||||||
|
|
||||||
// * Slightly more interesting; this will only diff the common parts, the rest is copied separately.
|
// * Slightly more interesting; this will only diff the common parts, the rest is copied separately.
|
||||||
auto commonSize = std::min(oldSnap.Particles.size(), newSnap.Particles.size());
|
auto commonSize = std::min(oldSnap.Particles.size(), newSnap.Particles.size());
|
||||||
FillHunkVectorPtr(reinterpret_cast<const uint32_t *>(&oldSnap.Particles[0]), reinterpret_cast<const uint32_t *>(&newSnap.Particles[0]), delta.commonParticles, commonSize * ParticleUint32Count);
|
FillHunkVectorPtr(reinterpret_cast<const uint32_t *>(oldSnap.Particles.data()), reinterpret_cast<const uint32_t *>(newSnap.Particles.data()), delta.commonParticles, commonSize * ParticleUint32Count);
|
||||||
delta.extraPartsOld.resize(oldSnap.Particles.size() - commonSize);
|
delta.extraPartsOld.resize(oldSnap.Particles.size() - commonSize);
|
||||||
std::copy(oldSnap.Particles.begin() + commonSize, oldSnap.Particles.end(), delta.extraPartsOld.begin());
|
std::copy(oldSnap.Particles.begin() + commonSize, oldSnap.Particles.end(), delta.extraPartsOld.begin());
|
||||||
delta.extraPartsNew.resize(newSnap.Particles.size() - commonSize);
|
delta.extraPartsNew.resize(newSnap.Particles.size() - commonSize);
|
||||||
@@ -257,11 +257,11 @@ std::unique_ptr<Snapshot> SnapshotDelta::Forward(const Snapshot &oldSnap)
|
|||||||
ApplySingleDiff<false>(Authors , newSnap.Authors );
|
ApplySingleDiff<false>(Authors , newSnap.Authors );
|
||||||
ApplySingleDiff<false>(FrameCount , newSnap.FrameCount );
|
ApplySingleDiff<false>(FrameCount , newSnap.FrameCount );
|
||||||
ApplySingleDiff<false>(RngState , newSnap.RngState );
|
ApplySingleDiff<false>(RngState , newSnap.RngState );
|
||||||
ApplyHunkVectorPtr<false>(PortalParticles, reinterpret_cast<uint32_t *>(&newSnap.PortalParticles[0]));
|
ApplyHunkVectorPtr<false>(PortalParticles, reinterpret_cast<uint32_t *>(newSnap.PortalParticles.data()));
|
||||||
ApplyHunkVectorPtr<false>(stickmen , reinterpret_cast<uint32_t *>(&newSnap.stickmen[0] ));
|
ApplyHunkVectorPtr<false>(stickmen , reinterpret_cast<uint32_t *>(newSnap.stickmen.data() ));
|
||||||
|
|
||||||
// * Slightly more interesting; apply the common hunk vector, copy the extra portion separaterly.
|
// * Slightly more interesting; apply the common hunk vector, copy the extra portion separaterly.
|
||||||
ApplyHunkVectorPtr<false>(commonParticles, reinterpret_cast<uint32_t *>(&newSnap.Particles[0]));
|
ApplyHunkVectorPtr<false>(commonParticles, reinterpret_cast<uint32_t *>(newSnap.Particles.data()));
|
||||||
auto commonSize = oldSnap.Particles.size() - extraPartsOld.size();
|
auto commonSize = oldSnap.Particles.size() - extraPartsOld.size();
|
||||||
newSnap.Particles.resize(commonSize + extraPartsNew.size());
|
newSnap.Particles.resize(commonSize + extraPartsNew.size());
|
||||||
std::copy(extraPartsNew.begin(), extraPartsNew.end(), newSnap.Particles.begin() + commonSize);
|
std::copy(extraPartsNew.begin(), extraPartsNew.end(), newSnap.Particles.begin() + commonSize);
|
||||||
@@ -291,11 +291,11 @@ std::unique_ptr<Snapshot> SnapshotDelta::Restore(const Snapshot &newSnap)
|
|||||||
ApplySingleDiff<true>(Authors , oldSnap.Authors );
|
ApplySingleDiff<true>(Authors , oldSnap.Authors );
|
||||||
ApplySingleDiff<true>(FrameCount , oldSnap.FrameCount );
|
ApplySingleDiff<true>(FrameCount , oldSnap.FrameCount );
|
||||||
ApplySingleDiff<true>(RngState , oldSnap.RngState );
|
ApplySingleDiff<true>(RngState , oldSnap.RngState );
|
||||||
ApplyHunkVectorPtr<true>(PortalParticles, reinterpret_cast<uint32_t *>(&oldSnap.PortalParticles[0]));
|
ApplyHunkVectorPtr<true>(PortalParticles, reinterpret_cast<uint32_t *>(oldSnap.PortalParticles.data()));
|
||||||
ApplyHunkVectorPtr<true>(stickmen , reinterpret_cast<uint32_t *>(&oldSnap.stickmen[0] ));
|
ApplyHunkVectorPtr<true>(stickmen , reinterpret_cast<uint32_t *>(oldSnap.stickmen.data() ));
|
||||||
|
|
||||||
// * Slightly more interesting; apply the common hunk vector, copy the extra portion separaterly.
|
// * Slightly more interesting; apply the common hunk vector, copy the extra portion separaterly.
|
||||||
ApplyHunkVectorPtr<true>(commonParticles, reinterpret_cast<uint32_t *>(&oldSnap.Particles[0]));
|
ApplyHunkVectorPtr<true>(commonParticles, reinterpret_cast<uint32_t *>(oldSnap.Particles.data()));
|
||||||
auto commonSize = newSnap.Particles.size() - extraPartsNew.size();
|
auto commonSize = newSnap.Particles.size() - extraPartsNew.size();
|
||||||
oldSnap.Particles.resize(commonSize + extraPartsOld.size());
|
oldSnap.Particles.resize(commonSize + extraPartsOld.size());
|
||||||
std::copy(extraPartsOld.begin(), extraPartsOld.end(), oldSnap.Particles.begin() + commonSize);
|
std::copy(extraPartsOld.begin(), extraPartsOld.end(), oldSnap.Particles.begin() + commonSize);
|
||||||
|
Reference in New Issue
Block a user