Eliminate &thing[0] pattern

crashfix_debugdraw
AnyOldName3 2 years ago
parent 7a0a11b30c
commit 4e8e2e1c60

@ -104,11 +104,11 @@ namespace ESSImport
esm.getSubNameIs("MAPD");
esm.getSubHeader();
data.resize(esm.getSubSize());
esm.getExact(&data[0], data.size());
esm.getExact(data.data(), data.size());
mGlobalMapImage = new osg::Image;
mGlobalMapImage->allocateImage(maph.size, maph.size, 1, GL_RGB, GL_UNSIGNED_BYTE);
memcpy(mGlobalMapImage->data(), &data[0], data.size());
memcpy(mGlobalMapImage->data(), data.data(), data.size());
// to match openmw size
// FIXME: filtering?
@ -135,7 +135,7 @@ namespace ESSImport
data.resize(width*height*4, 0);
image2->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE);
memcpy(image2->data(), &data[0], data.size());
memcpy(image2->data(), data.data(), data.size());
for (const auto & exploredCell : mContext->mExploredCells)
{

@ -248,7 +248,7 @@ namespace MWDialogue
MWScript::InterpreterContext interpreterContext(&actor.getRefData().getLocals(), actor);
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter);
interpreter.run (&code[0], code.size(), interpreterContext);
interpreter.run (code.data(), code.size(), interpreterContext);
}
catch (const std::exception& error)
{

@ -210,7 +210,7 @@ namespace MWGui
MWScript::installOpcodes (interpreter, mConsoleOnlyScripts);
std::vector<Interpreter::Type_Code> code;
output.getCode (code);
interpreter.run (&code[0], code.size(), interpreterContext);
interpreter.run (code.data(), code.size(), interpreterContext);
}
catch (const std::exception& error)
{

@ -591,7 +591,7 @@ void LocalMap::MapSegment::initFogOfWar()
std::vector<uint32_t> data;
data.resize(sFogOfWarResolution*sFogOfWarResolution, 0xff000000);
memcpy(mFogOfWarImage->data(), &data[0], data.size()*4);
memcpy(mFogOfWarImage->data(), data.data(), data.size()*4);
createFogOfWarTexture();
}
@ -612,7 +612,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm)
return;
}
Files::IMemStream in(&data[0], data.size());
Files::IMemStream in(data.data(), data.size());
osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(in);
if (!result.success())

@ -132,7 +132,7 @@ const MWState::Slot *MWState::Character::createSlot (const ESM::SavedGame& profi
void MWState::Character::deleteSlot (const Slot *slot)
{
int index = slot - &mSlots[0];
int index = slot - mSlots.data();
if (index<0 || index>=static_cast<int> (mSlots.size()))
{
@ -147,7 +147,7 @@ void MWState::Character::deleteSlot (const Slot *slot)
const MWState::Slot *MWState::Character::updateSlot (const Slot *slot, const ESM::SavedGame& profile)
{
int index = slot - &mSlots[0];
int index = slot - mSlots.data();
if (index<0 || index>=static_cast<int> (mSlots.size()))
{

@ -1148,7 +1148,7 @@ namespace MWWorld
{
std::vector<PositionCellGrid> vec;
vec.emplace_back(pos, gridCenterToBounds(getNewGridCenter(pos)));
mPreloader->abortTerrainPreloadExcept(&vec[0]);
mPreloader->abortTerrainPreloadExcept(vec.data());
mPreloader->setTerrainPreloadPositions(vec);
if (!sync) return;

@ -245,7 +245,7 @@ void CompressedBSAFile::readHeader()
if ((archiveFlags & 0x2) != 0)
{
mStringBuf.resize(totalFileNameLength);
input.read(&mStringBuf[0], mStringBuf.size()); // TODO: maybe useful in building a lookup map?
input.read(mStringBuf.data(), mStringBuf.size()); // TODO: maybe useful in building a lookup map?
}
size_t mStringBuffOffset = 0;

@ -58,7 +58,7 @@ namespace ESM
newSize -= 1; // don't read the null terminator yet
str.resize(newSize); // assumed C++11
stream.read(&str[0], newSize);
stream.read(str.data(), newSize);
if (static_cast<std::size_t>(stream.gcount()) == newSize)
{
if (hasNull)

@ -28,7 +28,7 @@ void convertFogOfWar(std::vector<char>& imageData)
return;
}
Files::IMemStream in(&imageData[0], imageData.size());
Files::IMemStream in(imageData.data(), imageData.size());
osgDB::ReaderWriter::ReadResult result = tgaReader->readImage(in);
if (!result.success())

@ -13,7 +13,7 @@ void GlobalMap::load (ESMReader &esm)
esm.getSubNameIs("DATA");
esm.getSubHeader();
mImageData.resize(esm.getSubSize());
esm.getExact(&mImageData[0], mImageData.size());
esm.getExact(mImageData.data(), mImageData.size());
while (esm.isNextSub("MRK_"))
{
@ -30,7 +30,7 @@ void GlobalMap::save (ESMWriter &esm) const
esm.writeHNT("BNDS", mBounds);
esm.startSubRecord("DATA");
esm.write(&mImageData[0], mImageData.size());
esm.write(mImageData.data(), mImageData.size());
esm.endRecord("DATA");
for (std::set<CellId>::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it)

@ -118,7 +118,7 @@ void ESM4::MediaLocationController::load(ESM4::Reader& reader)
{
#if 0
boost::scoped_array<unsigned char> mDataBuf(new unsigned char[subHdr.dataSize]);
reader.get(&mDataBuf[0], subHdr.dataSize);
reader.get(mDataBuf.get(), subHdr.dataSize);
std::ostringstream ss;
ss << mEditorId << " " << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n";

@ -231,7 +231,7 @@ void ESM4::Npc::load(ESM4::Reader& reader)
{
#if 1
boost::scoped_array<unsigned char> dataBuf(new unsigned char[subHdr.dataSize]);
reader.get(&dataBuf[0], subHdr.dataSize);
reader.get(dataBuf.get(), subHdr.dataSize);
std::ostringstream ss;
ss << mEditorId << " " << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n";

@ -125,7 +125,7 @@ void ESM4::Pathgrid::load(ESM4::Reader& reader)
{
#if 0
boost::scoped_array<unsigned char> mDataBuf(new unsigned char[subHdr.dataSize]);
reader.get(&mDataBuf[0], subHdr.dataSize);
reader.get(mDataBuf.get(), subHdr.dataSize);
std::ostringstream ss;
ss << mEditorId << " " << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n";

@ -110,7 +110,7 @@ void ESM4::Race::load(ESM4::Reader& reader)
// 00 00 00 00 9a 99 99 3e 00 00 a0 40 02 00 00 00
#if 0
unsigned char mDataBuf[256/*bufSize*/];
reader.get(&mDataBuf[0], subHdr.dataSize);
reader.get(mDataBuf, subHdr.dataSize);
std::ostringstream ss;
ss << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n";

@ -56,7 +56,7 @@ void ESM4::Script::load(ESM4::Reader& reader)
// For debugging only
#if 0
unsigned char mDataBuf[256/*bufSize*/];
reader.get(&mDataBuf[0], subHdr.dataSize);
reader.get(mDataBuf, subHdr.dataSize);
std::ostringstream ss;
for (unsigned int i = 0; i < subHdr.dataSize; ++i)
@ -94,7 +94,7 @@ void ESM4::Script::load(ESM4::Reader& reader)
std::cout << mEditorId << std::endl;
unsigned char mDataBuf[4096/*bufSize*/];
reader.get(&mDataBuf[0], subHdr.dataSize);
reader.get(mDataBuf, subHdr.dataSize);
std::ostringstream ss;
for (unsigned int i = 0; i < subHdr.dataSize; ++i)

@ -27,7 +27,7 @@ namespace Files
// Read in the next chunk of data, and set the read pointers on success
// Failure will throw exception.
const std::size_t got = File::read(mFile, mBuffer, toRead);
setg(&mBuffer[0], &mBuffer[0], &mBuffer[0] + got);
setg(mBuffer, mBuffer, mBuffer + got);
}
if (gptr() == egptr())
return traits_type::eof();

@ -121,9 +121,9 @@ boost::filesystem::path WindowsPath::getInstallPath() const
std::vector<char> buf(512);
int len = 512;
if (RegQueryValueEx(hKey, TEXT("Installed Path"), nullptr, nullptr, (LPBYTE)&buf[0], (LPDWORD)&len) == ERROR_SUCCESS)
if (RegQueryValueEx(hKey, TEXT("Installed Path"), nullptr, nullptr, (LPBYTE)buf.data(), (LPDWORD)&len) == ERROR_SUCCESS)
{
installPath = &buf[0];
installPath = buf.data();
}
RegCloseKey(hKey);
}

@ -386,7 +386,7 @@ namespace Gui
std::vector<char> textureData;
textureData.resize(width*height*4);
bitmapFile->read(&textureData[0], width*height*4);
bitmapFile->read(textureData.data(), width*height*4);
if (!bitmapFile->good())
fail(*bitmapFile, bitmapFilename, "File too small to be a valid bitmap");
bitmapFile.reset();
@ -394,7 +394,7 @@ namespace Gui
MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture(bitmapFilename);
tex->createManual(width, height, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8A8);
unsigned char* texData = reinterpret_cast<unsigned char*>(tex->lock(MyGUI::TextureUsage::Write));
memcpy(texData, &textureData[0], textureData.size());
memcpy(texData, textureData.data(), textureData.size());
tex->unlock();
// We need to emulate loading from XML because the data members are private as of mygui 3.2.0

@ -138,7 +138,7 @@ namespace l10n
if (message)
{
if (!args.empty() && !argNames.empty())
message->format(&argNames[0], &args[0], args.size(), result, success);
message->format(argNames.data(), args.data(), args.size(), result, success);
else
message->format(nullptr, nullptr, args.size(), result, success);
checkSuccess(success, std::string("Failed to format message ") + key.data());
@ -158,7 +158,7 @@ namespace l10n
return std::string(key);
if (!args.empty() && !argNames.empty())
defaultMessage.format(&argNames[0], &args[0], args.size(), result, success);
defaultMessage.format(argNames.data(), args.data(), args.size(), result, success);
else
defaultMessage.format(nullptr, nullptr, args.size(), result, success);
checkSuccess(success, std::string("Failed to format message ") + key.data());

Loading…
Cancel
Save